Skip to content

useTimeoutRafFn

Category
Export Size
395 B
Last Changed
5 days ago

Fire a callback once on the first animation frame at or after a delay, then stop

Demo

Usage

tsx
import { 
useTimeoutRafFn
} from '@reause/shared'
const
clear
=
useTimeoutRafFn
(() => {
/* runs once, on the first frame at or after 1000ms */ }, 1000) // cancel the pending timeout before the deadline
clear
()

Type Declarations

ts
export function useTimeoutRafFn(fn: () => void, delay: number | undefined): () => void

Source

Source · Demo · ahooks

Contributors

hairyf

Changelog

v0.1.6 on
f6851 - feat(shared): add useTimeoutRafFn (#942)

Released under the MIT License. v0.1.8