You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The callback of onSnapshot will never be triggered. I think it's by design of types.frozen. But is there any way to allow an MST reacting to the state of react-router?
The text was updated successfully, but these errors were encountered:
Hello! You cannot pass in classes in MST type definitions, and as said internal updates in frozen types will not trigger snapshots. You need to replace entirely the frozen property. Please try something like this! :)
// define the storeconstStore=types.model({locationState: types.maybe(types.frozen)},{updateLocationState(newState){this.locationState=newState}})// create the routerconsthistory=createBrowserHistory()// create the store instanceconststoreInstance=Store.create()// hook them uphistory.listen(newState=>storeInstance.updateLocationState(newState))onSnapshot(storeInstance,snapshot=>console.log(snapshot))ReactDOM.render(<Providerstore={storeInstance}><Routerhistory={history}>{...}</Router></Provider>)
For example, I wan't to sync the state of react router to MST. I tried the way mobx-react-router does.
The callback of onSnapshot will never be triggered. I think it's by design of types.frozen. But is there any way to allow an MST reacting to the state of react-router?
The text was updated successfully, but these errors were encountered: