Skip to content

How do I start the count down again after the first auto start? #139

Answered by ndresx
Darin1123 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you could create a state variable and use it as the countdown's key attribute to re-instantiate the countdown.

class CountDownComponent extends React.Component {
  state = { sendCount: 0 };

  reSendCode() {
    this.setState(({ sendCount }) => ({ sendCount: sendCount + 1 }));
  }

  render() {
    ...
        return (
            <CountDown
                key={this.state.sendCount}
                date={Date.now() + 30000}
                renderer={renderer}/>
        );
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Darin1123
Comment options

Answer selected by Darin1123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants