-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Persist changed value from true
to false
#26
Comments
Can i persist only nested store? |
Thanks for narrowing this down to a more minimal example @YanisKondakov , was hard to read through before. You still didn't quite provide an example of where this code is run:
For it to log twice, it must've been run twice, and that's not in the code you've listed. Since you have
Any persisted store will persist all its nested stores as well. But I'm struggling to fully understand what you meant here as there's some grammatical errors.
Did you mean to This is a problem I'm looking to fix soon once I've got Transforms #16 merged in, likely using a similar dotted syntax as above. Deep blacklists are relatively easy to implement, but deep whitelists are more complex (especially if any conflict handling is added). There are some workarounds for this, but they're all a bit hacky without Transforms 😕 Like one is to manually set your storage to the default of Side note:
can just be simplified to: isLoading: true Per https://mobx-state-tree.js.org/concepts/trees#creating-models , they're equivalent. |
Thank you @agilgur5 for the detailed answer. And sorry for my english. The example of where this code is run const { isLoading } = authStore;
console.log('isLoading => ', isLoading); is import React from 'react';
import createStore from './stores';
import { inject, observer, Provider } from 'mobx-react';
//This is a RootStore
const store = createStore();
const App = inject(({ authStore }) => ({ authStore }))(
observer(({ authStore }: any) => {
const { isLoading } = authStore;
console.log('isLoading => ', isLoading);
if (isLoading) {
return <SplashScreen />;
}
return (...);
}),
);
const AppProvider = () => (
<Provider rootStore={store} authStore={store.auth} profileStore={store.profile}>
<App />
</Provider>
);
export default AppProvider;
As you can see, |
true
to false
.
true
to false
.true
to false
true
to false
true
to false
Hi.
Environment info
React native info output:
The problem is, when i persist RootStore with nested AuthStore, all my boolean value form AuthStore become from
true
tofalse
.When i just console.log its value, i have this behaviour
It is RootStore with nested AuthStore
There is AuthStore
The text was updated successfully, but these errors were encountered: