Call the provided function on every animation frame.
import { useAnimationFrame } from "@evertbouw/pulleys";const SomeComponent = () => { const [number, setNumber] = useState(0); // no need to memoize const animate = () => { setNumber(cur => cur + 1); }; useAnimationFrame( animate, // call this function every frame number < 100, // until number is 100 ); return <div>{number}</div>;}; Copy
import { useAnimationFrame } from "@evertbouw/pulleys";const SomeComponent = () => { const [number, setNumber] = useState(0); // no need to memoize const animate = () => { setNumber(cur => cur + 1); }; useAnimationFrame( animate, // call this function every frame number < 100, // until number is 100 ); return <div>{number}</div>;};
function to be called every tick
pause the loop by passing false
false
Generated using TypeDoc
Call the provided function on every animation frame.
Example