Skip to content

useRafState

A hook that uses requestAnimationFrame to update state.

Usage

const Component = () => {
const [value, setValue] = useRafState(0);
return (
<button onClick={() => setValue((value) => value + 1)}>{value}</button>
);
};

Installation

Terminal window
npx atmx add hook use-raf-state