Appearance
useIntervalRafFn
Fire a callback repeatedly on animation frames, at a delay rounded up to the next frame
Demo
Usage
tsx
import { useIntervalRafFn } from '@reause/shared'
const clear = useIntervalRafFn(() => {
/* runs again and again, on the first frame at or after 1000ms since the last run */
}, 1000)
// stop the loop
clear()Type Declarations
ts
export interface UseIntervalRafFnOptions {
immediate?: boolean;
}
export function useIntervalRafFn(fn: () => void, delay: number | undefined, options?: UseIntervalRafFnOptions): () => void