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
Name | Type | Default | Note |
---|---|---|---|
callback | UseRafCallback | - | The callback to execute |
options.delay? | number | - | The delay between each frame in milliseconds |
options.enabled? | boolean | true | Whether the callback should be enabled |