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 function updater is called, its called with state, that is not guaranteed to be fresh. Original react setState, guarantees that prevValue is updater function is latest. This breaks when there are simultaneous setState calls. The state passed to second, third and so on updater functions are not reflecting previous changes.
Maybe ref could do here ?
The text was updated successfully, but these errors were encountered:
midas-myth
changed the title
Breaking rules of hooks leads to incorrect behaviour
Breaking rules of hooks leads to incorrect behaviour in useLocalStorage
Apr 4, 2024
react-use/src/useLocalStorage.ts
Line 63 in ade8d39
When function updater is called, its called with state, that is not guaranteed to be fresh. Original react setState, guarantees that
prevValue
is updater function is latest. This breaks when there are simultaneoussetState
calls. The state passed to second, third and so on updater functions are not reflecting previous changes.Maybe
ref
could do here ?The text was updated successfully, but these errors were encountered: