MicheleBertoli / react-count-to

Animated counter component for React.js
http://react-count-to.herokuapp.com
MIT License
61 stars 14 forks source link

how to redraw / restart counter via another handler in parent component #8

Closed azulkipli closed 7 years ago

MicheleBertoli commented 7 years ago

Hello @azulkipli, thank for opening the issue.

The CountTo component exposes a start method that you can access using refs, as follows:

<CountTo ref={(element => (this.element = element))} ... />
<button onClick={() => this.element.start()}>restart</button>

I couldn't think of a use case where you need to restart the counter (without changing the props), can you please explain me a little bit more so that I can find a better solution?