useRafReact animation hook that forces component to re-render on each requestAnimationFrame,
returns percentage of time elapsed.
import {useRaf} from 'react-use';
const Demo = () => {
const elapsed = useRaf(5000, 1000);
return (
<div>
Elapsed: {elapsed}
</div>
);
};
useRaf(ms?: number, delay?: number): number;
ms — milliseconds for how long to keep re-rendering component, defaults to 1e12.delay — delay in milliseconds after which to start re-rendering component, defaults to 0.// TODO: implement useRaf function notImplemented(..._args: any[]): any { throw new Error('Not implemented'); } export default notImplemented; export const useRaf = notImplemented;
Tests