Created
August 28, 2019 09:43
-
-
Save infinitypaul/5743da650cbb75f00a1036b646cc0bf8 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
const MyComponent = props => { | |
const innerFunction = () => { | |
// do something! | |
}; | |
useEffect(() => { | |
innerFunction(); | |
// The effect calls innerFunction, hence it should declare it as a dependency | |
// Otherwise, if something about innerFunction changes (e.g. the data it uses), the effect would run the outdated version of innerFunction | |
}, [innerFunction]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment