Skip to content

useIntervalRafFn

Category
Export Size
398 B
Last Changed
5 days ago

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

Source

Source · Demo · ahooks

Contributors

hairyf

Changelog

v0.1.7 on
1ce00 - feat(shared): add useIntervalRafFn (#941)

Released under the MIT License. v0.1.8