New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data in store changed without dispatching any actions #303
Comments
After unmounting the component, the atoms are unsubscribed and the value in the store is cleared. There are two solutions to save the state between page transitions:
const App = () => {
useAtom(todoListsAtom, () => null, [])
return (
<Router>
<Home path="/" />
<NotFound default />
</Router>
)
}
render(<Provider value={store}><App /></Provider>, rootElement);
const store = createStore(todoListsAtom) |
Hmm. When using symbols as the name of an atom, the state is cleared too. I don't think it should be like this. |
@stenin-nikita I tried solution 2 before, and I tried use Symbols or Strings as atom name, neither of them works. The solution 1 works for me as a workaround, but I hope we can have a better solution. |
@foisonocean @stenin-nikita thx for it discussion! We must to do some improvements and I create issues for it. |
CodeSandbox
Steps to reproduce in this CodeSandbox demo:
It is so weird, I use the devtools to check the reatom store after step1, I found the store is correct at that time. But after some router changes (without dispatching any actions), the store has been changed...
The text was updated successfully, but these errors were encountered: