question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to reset an atom to his default value?

See original GitHub issue

Hi,

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:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lironezracommented, Feb 4, 2021

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!

0reactions
drarmstrcommented, Feb 3, 2021

@lironezra - Do you have a reproducer for the issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found