Skip to content

Persist changed value from true to false #26

@ghost

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);

image

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: supportAsking for support with something or a specific use casesolution: duplicateThis issue or pull request already existssolution: intended behaviorThis is not a bug and is expected behaviorsolution: needs testThis issue requires creating a test to assuredly close out

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions