Add useTimeout snippet

This commit is contained in:
Angelos Chalaris
2019-08-21 13:20:57 +03:00
parent 4da67e8b6e
commit 958f2768c5
2 changed files with 51 additions and 1 deletions

View File

@ -8,7 +8,7 @@ A hook that implements `setInterval` in a declarative manner.
- Create a custom hook that takes a `callback` and a `delay`.
- Use the `React.useRef()` hook to create a `ref` for the callback function.
- Use the `React.useEffect()` hook to remember the latest callback.
- Use the `Rect.useEffect()` hook to set up the interval.
- Use the `Rect.useEffect()` hook to set up the interval and clean up.
```jsx