Closed jadbaz closed 9 years ago
It's not a completely different router package. redux-router usually work with react-router, and let you easily integrate you redux-app with router. But it doesn't limit to react-router, you can use other router and try to provide same api which react-router given now.
Is there an example that shows how I could use redux-router to integrate with my already configured react-router app? Thanks
As you can see here: https://github.com/rackt/redux-router/blob/master/examples/basic/index.js#L11, most of parts (Route, Link) are the same as what you do with react-router. redux-router just help you keep your routing state in redux's store.
Fair enough, But I still feel it should just integrate...
What does your "integrate" mean? What goal you want to achieve? If you even not use any routing state, you can leave it out of store and using just react-router is enough. But keeping routing state in store has some advantages, the one is that make mapStateToProps
can use state to create selector. You can do listening history, wrapping a component, and using reducer to handle routing state change yourself, but this just create another redux-router like functionality.
This project is an integration with React Router. If there's something in particular that is missing, please describe it in more detail.
My question is: Is it possible to be able to achieve all the above while keeping "Router" from react-router.
No.
Take a look at <Router>
source. It maintains the current state with setState()
and renders <RoutingContext>
.
Now take a look at <ReduxRouter>
source. It connects to the current state held in Redux store and also renders <RoutingContext>
.
The <RoutingContext>
is shared between them. However it doesn't make sense to use <Router>
directly because moving the state from inside <Router>
to Redux store is the whole point of this project.
In other words, is it possible for routing to work 100% using react-router and have redux "integration" as extra code that adds and does NOT replace while keeping control with react-router?
It is possible but it won't be “Redux way”. You can use React Router directly with Redux—but routing changes won't work with Redux DevTools, for example, and won't be dispatchable as actions.
Thanks Dan, Makes perfect sense!
Btw, what's the latest working documentation? README or basic example?
I don't know (I'm not the primary maintainer of this project), but I assume example should be up to date.
I understand the motivation but my why is it necessary to introduce a completely different router package instead of a set of bindings for react-router a-la react-redux? I think it would make sense since react-router is quite mature and very well documented.