Skip to main content

Function: useAnimationFrame()

function useAnimationFrame(callback, __namedParameters?): void;

Defined in: react/src/hooks/useAnimationFrame.ts:24

Call callback on every animation frame for as long as the component is mounted.

The callback is read on every frame, so it can be written inline and see the latest render without restarting the loop.

Parameters​

ParameterTypeDescription
callback(timestamp, deltaTime) => voidreceives the frame's timestamp and the milliseconds since the previous frame, which is 0 on the first one
__namedParametersUseAnimationFrameOptions-

Returns​

void