Skip to content

useRafState

Hook that returns the value and a function to set the value

state
low
test coverage
Last changed: 7 months 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

Installation

Library
CLI
Manual
typescript
import { useRafState } from '@siberiacancode/reactuse';

Usage

typescript
const [value, setValue] = useRafState(initialValue);

Demo

Api

Parameters

NameTypeDefaultNote
initialValueValue-The initial value

Returns

UseRafStateReturn<Value>

Type declaration

typescript
export type UseRafStateReturn<Value> = [Value, (value: Value) => void];

Source

SourceDemo

Contributors

D
debabin
debabin

Released under the MIT License.