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.

countdown restarts when a state changed

See original GitHub issue

I have a state from parent component App.js and pass my function change state as a props to child component and i am pretty sure that the state is not connected to countdown component.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
mledwardscommented, Jan 5, 2022

useMemo with an empty dependency array fixed this for me, as it only set the time on initial render

const time = React.useMemo(() => {
    return Date.now() + 120 * 1000;
  }, []);
2reactions
ndresxcommented, May 8, 2021

This should be hopefully fixed now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJs - Countdown reset unexpectedly
The reason why your counter is restarting, is because when you change the input field you're updating your state. Updating the state will ......
Read more >
react-native-timer-countdown-lucas - npm package
Provided the state changes only occur in component B, A component will not rerender. As a result, no more unintended timer restarts.
Read more >
react-countdown-circle-timer
Restart timer at any given time. Pass a key prop to CountdownCircleTimer and change the key when the timer should be restarted. Check...
Read more >
Agent Reboot Options
Allow the user to extend the time-out countdown up to a specified maximum. The maximum can be specified as either a duration or...
Read more >
How to Create a Countdown Timer Using ReactJS
ClearTimer : This function is use to reset the timer, means If you restart timer it clears time remaining from the previous countdown, ......
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