You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eslint automatically adds setField as a dependency in any useEffect that uses it. This causes an infinite loop. currently using // eslint-disable-next-line to prevent this behaviour. react-use-form-state isn't the only library i've seen that causes this so maybe it's something on my end or my understanding of hooks, but I feel like setField should be stable the same way dispatch in redux is a stable dependency
The text was updated successfully, but these errors were encountered:
keeganstothert
changed the title
setField as useEffect dependency causes infinite loop
setField in useEffect dependency causes infinite loop
Sep 5, 2019
I guess it makes sense that running setField should be a stable dependency (don't know much about how to achieve this) but there is a possible workaround for the situation displayed on the codesandbox posted by @alterx
You can add a condition inside the fetchData method to run your fetch + setField only if: a) The current input form fields are empty; b) Neither of them have been touched by the user yet
eslint automatically adds setField as a dependency in any useEffect that uses it. This causes an infinite loop. currently using
// eslint-disable-next-line
to prevent this behaviour. react-use-form-state isn't the only library i've seen that causes this so maybe it's something on my end or my understanding of hooks, but I feel like setField should be stable the same way dispatch in redux is a stable dependencyThe text was updated successfully, but these errors were encountered: