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
Would you please let me know why onSet is not triggered when using useRecoilState?
Or, is there anything that I misunderstood using useRecoilState and onSet?
The text was updated successfully, but these errors were encountered:
@hjk329
There are no issues with recoil-persist or onSet.
This is a problem that occurs very strictly in the mode.
This is related to an issue where two connections are required to identify a bug in Strict mode.
So in a production environment there will be no problem.
Try removing the React.StrictMode component
Try running it after building, not in dev mode.
Run the setter within the cleanup function of useEffect.
Hi, team.
I'm using recoil-persist to save atom in local storage.
I found out that
onSet
is not triggered when usinguseRecoilState
.However, it is executed when using
useSetRecoilState
.I'm using recoil
0.7.7
, the latest version, and Next.js12.3.2
.I looked through your document, describing
onSet
asSubscribe to changes in the atom value.
.Below is the source code. Atom is updated, but it is not stored in the local storage.
In my understanding, onSet should be called when the atom has new value (default: 'hj' -> new value: 'eden').
Using
useSetRecoilState
, however, it is saved in the storage.Would you please let me know why
onSet
is not triggered when usinguseRecoilState
?Or, is there anything that I misunderstood using
useRecoilState
andonSet
?The text was updated successfully, but these errors were encountered: