Skip to content

Because sometimes you want your effects to run right away

License

Notifications You must be signed in to change notification settings

apearce/use-immediate-effect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-immediate-effect

Because sometimes you want your effects to run right away

Installation

npm i use-immediate-effect

useImmediateEffect

Usage

When using useEffect or useLayoutEffect, the execution of the passed in function is deferred. There may be times when you want it to execute immediately, which is what useImmediateEffect does. The signature is the same as useEffect and useLayoutEffect.

import useImmediateEffect from 'use-immediate-effect';

function SomeComponent(props) {
    ...
    useImmediateEffect(() => {
        ...
        return () => {
            ...
        };
    }, [someDeps]);
    ...
}

About

Because sometimes you want your effects to run right away

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published