Pre Release: Redux-First Router — A Step Beyond Redux-Little-Router
James Gillmore
31213

Very nice. Another approach that I have been refining (and using in production for a while now) is similar to yours, especially in how <Link /> is handled. I took a different approach to handling route definitions. Routes are also created using actions and I supply a reducer to store the basic route definitions in the state. Each route is defined with some helpers that are used to transform url parameters to state, state to url parameters, and then a list of actions to perform when the url changes are also part of the route definition. This creates safe bidirectional bindings between url state and redux state. In addition, because routes can be defined either by an array of objects representing these props or by React components, we get both SSR-friendly routing, and the ability to load dynamic sub-routes. Subroutes would be useful for sites like udemy/blackboard/canvas, where whole sub-sites can be loaded with their own sub-routes.

Anyways, docs/examples at https://cellog.github.io/ion-router

I have been working on actual sites that use the code, and so have not yet put up examples of handling auth, but you can see example of dynamic sub-route loading:

https://cellog.github.io/examples/subroutes

and also handling displaying a placeholder loading component when redux state is not yet ready to display:

https://cellog.github.io/examples/loading

P.S. the documentation is a create-react-app static app running on github pages that uses 2 copies of ion-router, one for the front-facing docs, and then a second internal router with its own separate redux state tree that I use to update the internal fake browser. That was a fun exercise in something-no-one-else-will-ever-need-to-do-with-my-router :)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.