1

Without hopefully having to go into all the options and issues, does anyone have or know of a solid routing solution that is simple and just works for a React Redux combination? If so can you please provide a complete working reference including history, transitions, params, and so on?

Not sure how we ended up with 10 or more solutions to something that should be a core need for any real application, but the sheer number and constant flux (no pun intended) of the solutions out there make it seems like a nearly impossible task to zero in on anything in any timely manner. They seem to be growing in complexity as well and almost battling against each other in some cases.

If Dan or anyone else is going to link to the Redux real world example, please comment on the plan to address this issue/discussion. For simple router (or whatever we're calling it this week), or any of the other like Tiny, or the plethora of others, please clarify where history should come from (history lib router, your lib...) and why as well as how to handle params and such.

TIA

D Durham
  • 1,243
  • 2
  • 20
  • 42
  • What exactly do you need redux for in terms of routing? I feel like most use cases work just fine with `react-router`. Not to mention that now there's added efforts to keep it maintained. – ZekeDroid Apr 20 '16 at 16:45
  • Redux ties into routing for undo/redo or rewind or whatever you want to call it. However, we're also seeing some issues with RR leaking across abstractions and some warnings about slowness in Firefox, so we may be pursuing an alternate solution. – D Durham Apr 22 '16 at 12:45
  • `07:45:02.519 mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create1 reactrouter_react-router.js:3630:415` – D Durham Apr 22 '16 at 12:45

1 Answers1

1

I've had good success using react-router-redux to bridge React Router and Redux. The examples on the main page shows exactly where history should come from. You get the history object from React Router and you give it to react-router-redux (via syncHistoryWithStore).

react-redux-starter-kit is a very good starter repo that has React+Redux+Router(+alot of other stuff) all configured and working. Even if you do not start your work from their repo, you can browse the code to see how it is all put together.

Brandon
  • 38,310
  • 8
  • 82
  • 87
  • Thanks @Brandon... the starter does give me yet another straw man to peruse. However one initial thing I noted is it splits up the routes definition across several files (adds routes in one, history in another...) which may be needed, but does not seem optimal. I also started a few months back when it was still simple router, so I guess I'll have to bite the bullet and upgrade it and all the dependencies to get the latest API's. – D Durham Apr 20 '16 at 15:41
  • If this does end up fitting the bill, I'll come back and mark this as accepted, but am also curious to see if anyone else chimes in. – D Durham Apr 20 '16 at 15:42
  • Yeah I used it when it was "simple" also. The API has changed (for the better IMO). Now, when I want to transition to another URL, I can just use the routerMiddleware and use the navigation action creators, or I can just use the (essentially global) enhanced history object I created and call methods on it directly like so: `getHistory().push("some/new/url)` – Brandon Apr 20 '16 at 15:46
  • And there's no reason you can't put the routes and history all together in the same file if you want. The difference is just one of style. – Brandon Apr 20 '16 at 15:49