question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combining custom rendered and onComplete callback breaks the countdown

See original GitHub issue

Hi,

I’m using a where I have both a custom renderer and a onComplete callback as seen bellow:

<Countdown
              date={Date.now() + 5000}
              renderer={this.renderCountdown}
              onComplete={() => {
                this.setState({ isAvailable: true });
              }}
renderCountdown({ hours, minutes, seconds, completed }) {
    if (completed) {
      // Render a complete state
      return (
        <div className="countdown">
          Available <span>now!</span>
        </div>
      );
    } else {
      // Render a countdown
      return (
        <div className="countdown">
          Available in
          <span className="clock">
            {hours} hours {minutes} minutes {seconds} seconds
          </span>
        </div>
      );
    }
  }

The reason I have it like this is because I have other child components that need from that isAvailable state property, but with this combination at the end of the countdown the custom renderer will not enter the completed verification, instead will always show the clock stopped at the initial start time.

Thanks so much for any help and the super useful component!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ZuechBcommented, Mar 27, 2019

I am also having this issue, I downloaded the npm “react-countdown-now”: “^2.1.0” and using the latest ver. of next.js this.setState({ blah: true }) does not work within the complete method call for me.

1reaction
lmartinscommented, Feb 2, 2019

@ndresx Hey Martin, sorry I’ve missed your initial comment. On my project I can replicate it consistently, so my guess is something else is interfering. For now I’ve approached differently. Thanks so much for looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wait for all threads to finish, using ExecutorService?
Basically on an ExecutorService you call shutdown() and then awaitTermination() : ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(.
Read more >
Warning: Cannot update a component (`xxx`) while rendering ...
In the parent component I update the recoil state with the onCompleted callback option of Apollo (but the same issue happens with useEffect...
Read more >
DevicePolicyManager - Android Developers
Uninstalls all custom trusted CA certificates from the profile. ... However, since Android 11, this combination is not possible.
Read more >
Mintegral SDK Integration - Android
For Android Support, SDK provides callback for initialization status in version ... //Customize the size according to your needs. public static final int ......
Read more >
Prebid Plugin for Brightcove (Videojs) Player for Header Bidding
Single Ad Playback via VAST XML at one or more ad break positions within a ... You may also replace this plugin with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found