Function useAnimationFrame

  • Returns the protocol that starts and stops an animation loop.

    When start is called the animation loop starts invoking the provided callback using requestAnimationFrame. If an animation is already started then it is stopped and started with the new callback.

    An animation is automatically stopped on unmount.

    An animation should be started/stopped after the component is mounted. Before that, it is a no-op.

    Returns [start: ((cb) => void), stop: (() => void)]