1 month ago

How to enable strict mode in mobx store, react-native.

Posted 1 month ago by Gabotronix

Hi everybody, how can I enable strict mode for my mobx stores in my react-native map, I use mobx stores along with react context API and hooks. After reading docs strict mode makes it so I can only change observable state in actions.


import React from 'react'
import { ThemeStore }  from '../stores/ThemeStore.js'
import { PostStore }  from '../stores/PostStore.js'

export const storesContext = React.createContext({
  postStore: new PostStore(),
  themeStore: new ThemeStore(),


import { observable, computed, action, flow } from "mobx";
import axios from 'axios';

export class PostStore
    @observable postMessage = 'Nothing to see here';
    @observable post = {};
    @observable posts = [];
    @observable pagination = {};
    @observable postCount = 0;

    @computed get visiblePosts()
        return this.posts.filter( post => post.isVisible);


Please sign in or create an account to participate in this conversation.