@react-hookbox/after-loading-effect
useAfterLoadingEffect
Install
npm install --save @react-hookbox/after-loading-effect
or
yarn add @react-hookbox/after-loading-effect
Usage
useAfterLoadingEffect
Both for JavaScript and Typescript:
import { useAfterLoadingEffect } from '@react-hookbox/after-loading-effect';
// OR
// import useAfterLoadingEffect from '@react-hookbox/after-loading-effect';
// then
useAfterLoadingEffect(isLoading, () => {
// this will work only when isLoading turned from true to false
console.log('Loading ended! 🎉🎉🎉');
});
Params
useAfterLoadingEffect
-
isLoading: boolean
. When this changes from true to false, then the callback fn will be called in effect-ive time. -
fn: EffectCallback
. the callback function to call after loading ends. The return value of this function will be provided to the effect hook. -
useEffectHook = useEffect
. (Optional) The hook to use for calling the callback function.
License
MIT © hakobpogh