Created
July 5, 2020 10:46
-
-
Save amass01/0d7fbbfb05f5cd0618906d992e3e7693 to your computer and use it in GitHub Desktop.
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"; | |
/** | |
* useMountEffect is a custom hook to run an effect on mount | |
* only once, it accepts an effect/function and executes it | |
* only after succesful mount (empty array as second argument | |
* in useEffect call) | |
* | |
* @param {*} fun - effect to run on mount | |
*/ | |
const useMountEffect = (fun) => useEffect(fun, []); | |
export default useMountEffect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment