Skip to content

Latest commit

Β 

History

History
31 lines (21 loc) Β· 587 Bytes

useRaf.md

File metadata and controls

31 lines (21 loc) Β· 587 Bytes

useRaf

React animation hook that forces component to re-render on each requestAnimationFrame, returns percentage of time elapsed.

Usage

import {useRaf} from 'react-use';

const Demo = () => {
  const elapsed = useRaf(5000, 1000);

  return (
    <div>
      Elapsed: {elapsed}
    </div>
  );
};

Reference

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.