Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause timer #2

Open
dsernst opened this issue Jul 27, 2015 · 2 comments
Open

Pause timer #2

dsernst opened this issue Jul 27, 2015 · 2 comments

Comments

@dsernst
Copy link
Contributor

dsernst commented Jul 27, 2015

It would be mighty handy to be able to pause the timer. 😄

@rvierich
Copy link
Contributor

rvierich commented Sep 2, 2015

@dsernst Agreed! (Sorry for the late response)

One approach is to use refs to achieve this, but as of React 0.14 Beta 1, refs will return an element's DOM node instead of the element itself.

Another approach is to check for prop changes in componentDidUpdate and call an appropriate method in response to the change (as described here).

In this case, a paused prop could handle this. When it changes to true, we'd call this.pause(). When changed to false, we'd call this.resume().

What do you think about this approach? Do you still need this functionality?

@dsernst
Copy link
Contributor Author

dsernst commented Sep 3, 2015

Yes, that approach sounds good!

I implemented this feature myself by keeping track of the remaining time in a parent component, then when paused is pressed switching in a dummy component to statically show the paused time, then when the resume button is pressed switching the timer back in with initial time set to remaining time from the parent component. It works... but feels mighty clunky. 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants