'Mobx Strict mode warning when updating observable property of object
in my react-native app I use mobx for state management, I just noticed I'm getting a strict mode warning when changing the value of an observable object.
My error:
[MobX] Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: [email protected]
How I update mobx state
let copy = userStore.user;
copy.filterMood = 'newValue';
userStore.setUser(copy);
User store
import { makeAutoObservable } from "mobx";
import { makePersistable } from 'mobx-persist-store';
export class UserStore
{
constructor()
{
makeAutoObservable(this);
}
user = false;
setUser(payload)
{
this.user = payload;
}
}
import { UserStore} from '../stores/UserStore.js'
export const storesContext = React.createContext({
userStore: new UserStore()
});
configure({ enforceActions: "observed" });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
