1
votes

I want to use mobx-react and mobx. So I created a file store.ts like this :

import { observable} from "mobx";
class store {
     @observable test= ""; // path des Ws local    
}
export default store;

In my app component, I have :

import store from "../store/store"; import { observer } from "mobx-react";

 componentDidMount() {       
        console.log("Store : ", store.test)
    }

But I have one error : "test doesn't exist" If I just try console.log(store). It builds, but I have an error in navigator, "default' is no longer part of the public MobX api"

Do you have an idea ?

1

1 Answers

1
votes

You should create an instance of your store and export it.

import { observable} from "mobx";
class store {
     @observable test= ""; // path des Ws local    
}
export default new store();