-
Notifications
You must be signed in to change notification settings - Fork 199
Description
This is related to and a continuation of #172. I spent some time this weekend getting redux-router up and running with react-router v2 and found myself rewriting logic almost verbatim from react-router into redux-router. I agree with the goals of redux-simple-router in that we should be leveraging react-router for the logic while ensuring that it can be used in a redux friendly way. However, I think based on the comments in #172 (and my own belief) there is a desire to continue this project because of some of the extra functionality it offers.
Therefore, I am proposing a possible middle ground style approach where we push as much logic into react-router and simplify this library while still maintaining some of the core features. This is only really possible with some of the new features made available in Version 2.x of React-Router which is currently in release candidate mode.
I've implemented a proof of concept here which has both the client and server examples up to date and working (the tests still need some updates though). The library contains about half the code of the original while maintaining the core features, although losing a few more advanced capabilities. I'd like to gauge wether or not these things are critical to the community.
Feature breakdown:
Maintains the following:
- dispatch actions which call the history API (i.e. push, pop, replace)
- updates to the router reducer result in calls to the history API
- full router state is present in the reducer (entire location object, query params, accessed anywhere with redux's
connect)
Removes the following:
- dynamic route updates, i.e. replaceRoutes (becuase React-Router does not allow this...yet?)
- getRoutes ability which allowed the routes to be paramertized by the store
I think the getRoutes removal will be the most jarring at first. For example @erikras uses it in his well known example. However I think that the higher order wrapper method for authentication and authorization in routes as shown in @joshgeller 's example works quite well.
Other benefits
- Far less code, much easier to maintain and bugfix.
- Server-side rendering is almost identical to
react-router - Even more closely aligned with
react-routerAPI:- no need to copy over bug fixes
- can refer users to
react-router's docs - easier for users to switch between this library and
redux-simple-router
Way forward
Would love to get thoughts from @Scarysize @acdlite @omnidan (and other contributors) as well as current users on this