Replies: 1 comment
-
// eslint-disable-next-line react-hooks/exhaustive-depsabove the line with the error. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How do you tell useEffect you don't care about without making exhaustive deps mad?
I only want this to run when the app first loads.
And more specifically when
provideris available.provideris initialized asnull. At some point when the app first loads,provideris initialized. That's when I want this to run.But the React hooks plugin is telling me to add
dispatchandtxsPending.I don't want the code to run when
txsPendinganddispatchchanges. And yet, I need these variables and functions in theuseCallback.If I add
txsPendinganddispatchto the dep array, won't the codeblock be called three times?Once when dispatch is created, and everytime
txsPendingis changed (txsPendingis localstate)? Which I don't want.How is
useCallbackdep array satisfied here? While also making sure it only runs when I want it to?Beta Was this translation helpful? Give feedback.
All reactions