Replies: 1 comment
-
// eslint-disable-next-line react-hooks/exhaustive-deps above 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
-
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
provider
is available.provider
is initialized asnull
. At some point when the app first loads,provider
is initialized. That's when I want this to run.But the React hooks plugin is telling me to add
dispatch
andtxsPending
.I don't want the code to run when
txsPending
anddispatch
changes. And yet, I need these variables and functions in theuseCallback
.If I add
txsPending
anddispatch
to the dep array, won't the codeblock be called three times?Once when dispatch is created, and everytime
txsPending
is changed (txsPending
is localstate)? Which I don't want.How is
useCallback
dep array satisfied here? While also making sure it only runs when I want it to?Beta Was this translation helpful? Give feedback.
All reactions