Function useAnimationFrame

  • Call the provided function on every animation frame.

    Example

    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>;
    };

    Parameters

    • tick: (() => void)

      function to be called every tick

        • (): void
        • Returns void

    • running: boolean = true

      pause the loop by passing false

    Returns void

Generated using TypeDoc