Skip to content

useOnce

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

humor
low
test coverage
Last changed: 7 months ago

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

SourceDemo

Contributors

D
debabin
debabin

Released under the MIT License.