Timer Hooks

The react-hookedup library also provides Hooks for dealing with timers. If we simply create a timer using setTimeout or setInterval in our component, it will get instantiated again every time the component is re-rendered. This not only causes bugs and unpredictability, but can also cause a memory leak if the old timers are not freed properly. Using timer Hooks, we can avoid these problems completely, and easily use intervals and timeouts.

The following timer Hooks are provided by the library:

  • The useInterval Hook, which is used to define setInterval timers (timers that trigger multiple times) in React components
  • The useTimeout Hook, which is used to define setTimeout timers (timers that trigger only once after a certain amount of time)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.189