Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created September 1, 2020 09:30
Show Gist options
  • Save ccapndave/b0a323e823469d103ba7d65d68b034e9 to your computer and use it in GitHub Desktop.
Save ccapndave/b0a323e823469d103ba7d65d68b034e9 to your computer and use it in GitHub Desktop.
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