Created
September 1, 2020 09:30
-
-
Save ccapndave/b0a323e823469d103ba7d65d68b034e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let useMyFunction = (myfunc, deps) => { | |
React.useEffect(() => { | |
myfunc(); | |
}, deps); | |
}; | |
// In a component | |
useMyFunction(() => console.log(a), [a]); | |
// Because a is bound at the point I create the function to pass into the hook, it never updates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment