Comments (3)
Hey thanks for the issue (and for the great detail) - good find.
My first question is: what is the case for passing the history property from a RouterStore
instance in to a Router
component, as opposed to just passing the return history value from syncHistoryWithStore
as the README example does? i.e:
const browserHistory = createBrowserHistory();
const routingStore = new RouterStore();
const stores = {
// Key can be whatever you want
routing: routingStore,
// ...other stores
};
const history = syncHistoryWithStore(browserHistory, routingStore);
ReactDOM.render(
<Provider {...stores}>
<Router history={history}>
<App />
</Router>
</Provider>,
document.getElementById('root')
);
Maybe I'm missing a use case.
But in general I think your current workaround is the correct implementation anyway - meaning the history
and location
properties should be required in the typings:
export class RouterStore {
history: History;
location: Location;
}
Would this solve the problem?
Even though technically those properties can be undefined/null, using this library as described in the docs would mean that any useful application of using the a RouterStore
would be in situation where the history and location properties have been set (at any point after the syncHistoryWithStore
function call).
from mobx-react-router.
Well, I had just posted the issue when I realized that the "correct" way is to use the history returned from syncHistoryWithStore
, so I guess there is no use case for it.
But anyway, I agree with you that we should probably just change the typings to be required no matter what. That would fix the issue (would also mean we wouldn't have to check for undefined everywhere, yay!)
from mobx-react-router.
Added in release 4.0.3
https://github.com/alisd23/mobx-react-router/releases/tag/v4.0.3
from mobx-react-router.
Related Issues (20)
- Newly created store missing history and location in react-router 6.x HOT 31
- mobx-react-router/Router not exported HOT 1
- Doc with react-router-v6 is missing.
- Remove support for decorators
- Nested routes HOT 2
- Any way to update a hash route? HOT 1
- .. with Typescript Property 'routing' does not exist on type 'Readonly<{ children?: ReactNode; }> & Readonly<{}> HOT 4
- How to get route params? HOT 4
- update peer dependencies HOT 1
- [question] this vs react-router-dom HOT 1
- n element descriptor's .kind property must be either “method” or “field” HOT 2
- Issue with TypeScript when trying to use SynchronizedHistory from RouterStore HOT 1
- How to send params to other pages? HOT 3
- Compatible with Server Side Rendering? HOT 2
- Update Peer Dependency HOT 3
- Server Side Rendering is broken in v4.0.6 HOT 1
- Pass state with RoutingStore.push() HOT 1
- Looking for maintainers HOT 11
- will v3 with latest mobx? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobx-react-router.