Skip to content

How to restart the timer ? #33

Open

Description

@shafarizkyf
No description provided.

Activity

  1. crup commented on Feb 28, 2020

    @crup
    Contributor

    For now you can restart the timer by updating the key.
    Here's the sample code below:

    import React, { useState } from "react";
    import ReactTimer from "@xendora/react-timer";
    import "./styles.css";
    
    export default function App() {
      const [isRestarted, setIsRestarted] = useState(false);
      return (
        <div className="App">
          <ReactTimer
            start={0}
            key={isRestarted}
            end={value => value === 30}
            onEnd={value => console.log("ENDED WITH VALUE", value)}
            onTick={value => value + 1}
          >
            {time => <div>{time}</div>}
          </ReactTimer>
          <button
            onClick={() => {
              setIsRestarted(!isRestarted);
            }}
          >
            Restart
          </button>
        </div>
      );
    }

    https://codesandbox.io/s/autumn-feather-fhxyb

    @Bryze Let's evaluate if the need restart functionality as a prop.
    @shafarizkyf Any suggestions regarding api for restarting the timer are most welcome.

  2. added
    enhancementNew feature or request
    @next-releaseFunctionality will be fixed/added in next release
    on Apr 29, 2020
  3. linked a pull request that will close this issueWIP: V2 release #36on Apr 29, 2020
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

    @next-releaseFunctionality will be fixed/added in next releaseenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions