Assume following structure
stores/
RouterStore.js
UserStore.js
index.js
each of ...Store.js files is a mobx store class containing @observable and @action. index.js just exports all stores, so
import router from "./RouterStore";
import user from "./UserStore";
export default {
user,
router
};
What is correct way to access one store inside another? i.e. inside my UserStore, I need to dispatch action from RouterStore when users authentication changes.
I tired import store from "./index" inside UserStore and then using store.router.transitionTo("/dashboard") (transitionTo) is an action within RouterStore class.
But this doesn't seem to work correctly.