mobx-react-router
mobx-react-router copied to clipboard
will v3 with latest mobx?
Does anyone know if v3 of this package can be made to work with latest mobx? When I upgrade mobx, I get store.location undefined
I upgrade this tool with mobx v6 and make a pull request. Before the pr is merged, you can use @superwf/mobx-react-router temporarily.
Happens to me too, will love to make it work with mobx v6
If you're stuck on react-router v5, and want to incorporate mobx v6, you can do the following:
import { RouterStore, syncHistoryWithStore } from 'mobx-react-router';
import { createBrowserHistory } from 'history';
import { makeObservable } from 'mobx';
export const routerStore = new RouterStore();
export const browserHistory = syncHistoryWithStore(createBrowserHistory(), routerStore);
makeObservable(routerStore);
The only important call here is makeObservable(routerStore). This picks up the existing observable decorator and wires everything up.