Last active
June 29, 2022 08:31
-
-
Save avcs06/52af2e292e1c964f0e564447c03526dd to your computer and use it in GitHub Desktop.
Execute the effect when atleast one of the dependancies is truthy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
const useSomeEffect = (callback, deps) => { | |
useEffect(() => { | |
if (deps.reduce((a, c) => a || Boolean(c), false)) callback(); | |
}, deps); | |
}; | |
export default useSomeEffect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment