Skip to content

Pause timer #2

Open
Open

Description

@dsernst

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

Activity

  1. rvierich commented on Sep 2, 2015

    @rvierich
    Contributor

    @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?

  2. dsernst commented on Sep 3, 2015

    @dsernst
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions