3 ms·
It's been a while since I used react-router, but I think this is one place where the Flux flow is better. Navigation is state, so we built a store to track it.
by lobster_johnson 11y ago
It's been a while since I used react-router, but I think this is one place where the Flux flow is better.
Navigation is state, so we built a store to track it. It mediates between a UI model (which abstracts the window location and pushstate stack) and an internal state. Routing involves dispatching an action to request a specific URL, and changing the view to the navigation state is handled by the app's root "application" component, which then sends parameters onward to its current "view" component. There's a simple mapping of route names to views.
- girvo 11y agoWe built a very similar component for React, hooked into Flummox. The nice part is that async "just worked", and having the entire router available as a Flux store with actions that you can fire to change the page made integration powerful. We also added some extra little code to make it run on the server: the <Link> component renders down to an <a> tag, and the router runs correctly, so everything works isomorphically, and as a neat bonus the bulk of the site works without Javascript enabled.