[Question] How to reset an atom to his default value?
See original GitHub issueHi,
I’m trying to reset atom to his default value when user logout from my application with the useRecoilCallBack function like that:
const resetRecoilAtomState = useRecoilCallback(({ reset }) => () => { reset(userState); });
userState
that passed to reset
is the atom, I’m also tried to pass the userState
atom value to reset
and it not working either, what am I doing wrong?
Thanks for the help!
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to reset Atom packages to default - Stack Overflow
If you're on windows, my atom seems to be stored at "C:\Users\{user}\AppData\Local\atom". Here I have access to a folder named "packages".
Read more >atomWithDefault - Jotai
This is a function to create a resettable primitive atom. Its default value can be specified with a read function instead of a...
Read more >useResetRecoilState(state) | Recoil
Using useResetRecoilState() allows a component to reset the state to its default value without subscribing the component to re-render whenever the state ...
Read more >Reset Atom Hub - Vera
1. Reset Wi-fi and network settings to factory defaults. With the Atom still plugged into the USB port for power, press the reset...
Read more >Reset to default value only when all the fields are filled
I have also added few checks for missing fields, but when any field is empty my all the entered data get reset to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @drarmstr,
I tired to reproduce the issue, but it seems to work in codesanbox. Here is my code: https://codesandbox.io/s/charming-margulis-nuz15?file=/src/App.js.
I find out my mistake somewhere after user logged out.
useResetRecoilState
worked as expected!Thanks anyway!
@lironezra - Do you have a reproducer for the issue?