TimerSafely
Timer functions for executing code in the future that are safely cleaned up when the react component unmounts.
Usage
You can replace your calls to setTimeout(fn, 500)
with this.setTimeout(fn, 500)
(just prepend this.
) and everything will be properly cleaned up for you.
@timerSafely { // prepend `this.` this this this this } { return <main> <button onClick=thishandleAsyncTimer>async timer</button> </main> }
License
react-timer-safely
is released under the MIT license.