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
When I put setData in useEffect, I have an infinite loop issue as opposed to using the regular setState? For setState in my case not to have an infinite loop I need to use the callback setState variant which is setState(prevState => ({ ...prevState, ...newState }));, but I can't resolve this way using setData like setData(prevState => ({ ...prevState, ...newState }));.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I put
setData
inuseEffect
, I have an infinite loop issue as opposed to using the regularsetState
? ForsetState
in my case not to have an infinite loop I need to use the callback setState variant which issetState(prevState => ({ ...prevState, ...newState }));
, but I can't resolve this way usingsetData
likesetData(prevState => ({ ...prevState, ...newState }));
.Beta Was this translation helpful? Give feedback.
All reactions