Skip to content

useRaf ​

utilities
test coverage
Last changed: 28 days ago

TIP

This hook uses requestAnimationFrame browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api

Hook that defines the logic for raf callback

typescript
import { useRaf } from '@siberiacancode/reactuse';

Usage ​

typescript
useRaf(() => console.log('callback'));

Demo ​

Api ​

Parameters

NameTypeDefaultNote
callbackUseRafCallback-The callback to execute
options.delay?number-The delay between each frame in milliseconds
options.enabled?booleantrueWhether the callback should be enabled

Source ​

Source • Demo

Contributors ​

Avatardebabin

Released under the MIT License.