You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. 😕
Activity
rvierich commentedon 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
componentDidUpdateand call an appropriate method in response to the change (as described here).In this case, a
pausedprop could handle this. When it changes totrue, we'd callthis.pause(). When changed to false, we'd callthis.resume().What do you think about this approach? Do you still need this functionality?
dsernst commentedon 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. 😕