In my Typescript application, I rely on Mobx for persistence and have created a singleton class called MyStore to manage the store:
export class MyStore {
@observable something;
@observable somethingElse;
}
export myStore:MyStore = new MyStore();
The MyStore class is located in a file called "data/store/MyStore". So why do I find myself unable to simply import it into all of my components like this:
import { myStore } from "data/store/MyStore";
Shouldn't I be able to just import myStore and begin using it without any issues?
Instead, why am I required to go through the trouble of using createContext and useStore to access the store? It seems like I should be able to access it simply by importing it. What am I overlooking here?