Skip to content

useOnce ​

Hook that runs an effect only once. Please do not use it in production code!

humor
test coverage
Last changed: last month

WARNING

This hook will run effect only once even in strict mode. Please do not use it in production code!

Installation ​

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

Usage ​

typescript
useOnce(() => console.log('effect once'));

Demo ​

Api ​

Parameters

NameTypeDefaultNote
effectEffectCallback-The effect to run

Type declaration ​

typescript
import type { EffectCallback } from 'react';

Source ​

Source • Demo

Contributors ​

D
debabin
debabin

Released under the MIT License.