Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 19:41:17 +02:00
parent e7988c0065
commit 9661870d03
6 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,7 @@ Runs an animating function, calling it before every repaint.
- Use the `useRef()` hook to create two variables. `requestRef` will hold the last request id and `previousTimeRef` will hold the last timestamp.
- Define a function, `animate`, which handles updating these variables, runs the `callback` and calls `Window.requestAnimationFrame()` perpetually.
- Use the `useEffect()` hook with an empty array to initialize the value of `requestRef` using `Window.requestAnimationFrame()`. Use the `return` value and `Window.cancelAnimationFrame()` to clean up when the component unmounts.
- Use the `useEffect()` hook with an empty array to initialize the value of `requestRef` using `Window.requestAnimationFrame()`. Use the returned value and `Window.cancelAnimationFrame()` to clean up when the component unmounts.
```jsx
const useRequestAnimationFrame = callback => {