|
useEffect(() => { |
|
cancelAnimationFrame(rafRef.current); |
|
|
|
rafRef.current = requestAnimationFrame(animate); |
|
|
|
// cancel raf on unmount |
|
return () => { |
|
cancelAnimationFrame(rafRef.current); |
|
}; |
|
}, [animate]); |
animate is defined just above, with a new reference at each render.
use-scramble/src/index.ts
Lines 376 to 385 in e632c71
animateis defined just above, with a new reference at each render.