Combining custom rendered and onComplete callback breaks the countdown
See original GitHub issueHi,
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:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@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.