3 ms·
> I am not sure what the Angular or React solutions are but with vue just use the vue router. For React there's a couple, but most of them boil down to the sam
by crooked-v 8y ago
> I am not sure what the Angular or React solutions are but with vue just use the vue router.
For React there's a couple, but most of them boil down to the same basic idea that you've got switch statements that decide which components to render based on router state (rather than there being anything "special" about routing entry points), and then something like a <Link> component that just acts like an <a> tag but triggers the client routing change instead.
- ThePhysicist 8y agoI used react-router before but absolutely hated how it mixes presentational logic with URL matching. For new projects I just use a small routing helper that’s written using React context and that performs URL matching the old fashioned way (a list of pattern with parameters that are routed to specific components). Works really well on all modern browsers and is less than 200 lines of code. It even allows for reverse routing (use a view name and parameters to generate a URL) which to my knowledge isn’t implemented in react-router.
- crooked-v 8y ago> I used react-router before but absolutely hated how it mixes presentational logic with URL matching. You may like redux-first-router, which has the URL literals as part of a routemap attached to the Redux store, and then has all routing in the app actually just be the dispatching of Redux actions. Your navigational components then end up with stuff like: <Link to={{ type: THAT_PAGE_WITH_THE_STUFF }}>Link text here</Link> ...where the Link is actually just a convenience helper component wrapping <a> that dispatches the action and provides a browser-friendly href reverse-engineered from the routemap if possible.