Open

Description
Hi.
Environment info
React native info output:
System:
OS: Linux 5.3 Ubuntu 18.04.4 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory: 12.78 GB / 31.23 GB
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 12.16.1 - /usr/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.13.4 - /usr/bin/npm
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
The problem is, when i persist RootStore with nested AuthStore, all my boolean value form AuthStore become from true
to false
.
When i just console.log its value, i have this behaviour
const { isLoading } = authStore;
console.log('isLoading => ', isLoading);
It is RootStore with nested AuthStore
import { types } from 'mobx-state-tree';
import { connectReduxDevtools } from 'mst-middlewares';
import AuthStore from './auth.store';
import { persist } from 'mst-persist';
import AsyncStorage from '@react-native-community/async-storage';
let store: any = null;
export default () => {
if (store) return store;
const RootStore = types
.model('RootStore', {
identifier: types.optional(types.identifier, 'RootStore'),
auth: AuthStore,
});
store = RootStore.create({
auth: {
isLoading: true,
},
});
/**
* Not working in debug mode
*/
persist('rootStore', store, {
storage: AsyncStorage,
}).then(() => {});
// @ts-ignore
if (__DEV__ && Boolean(window.navigator.userAgent)) {
connectReduxDevtools(require('remotedev'), store);
}
return store;
};
There is AuthStore
import { types } from 'mobx-state-tree';
const AuthStore = types
.model({
isLoading: types.optional(types.boolean, true),
});
export default AuthStore;