6 ms·
React Router 6
- sattoshi 5y agoUsually new versions excite me, but with React Router I can only wonder: how much of a re-write will I need to do?
- 0des 5y agoHow is this sustainable?
- postalrat 5y agoWrite fewer tests and change quickly.
- 0des 5y ago> Write fewer tests Sold.
- Griffinsauce 5y agoWrite end-to-end tests that test behavior instead of implementation.
- postalrat 5y agoI think it's time to start testing tests. The first test will be metrics how often tests are changed when the things they test are changed. If it's close at all to 1 to 1 then the test fails.
- shadowofasun 5y agoIt is only sustainable for large businesses, which increasingly are the only businesses.
- TranquilMarmot 5y agoSeriously, the upgrades are always such a massive pain. The v5 -> v6 doc is already making me dizzy just from how long it is https://reactrouter.com/docs/en/v6/upgrading/v5 https://reactrouter.com/docs/en/v6/upgrading/v5
- Griffinsauce 5y agoPeople should really take Next.js as an example here. They make sure it's backwards compatible as much a possible and when it's not they provide a codemod or the app tells you what's wrong (and how to fix it!) when you try to run it. If course the latter is hard/impossible with a lower level library like this but the former is def. possible. Emotion css decided to rename/reshuffle all their packages and imports in v11 which was a massive pain, but with the provided codemod that migration was not too painful.
- yurishimo 5y agoI think we're at an interesting time for React routing. It seems like a ton of shops are standardizing on Next.js as a base for new projects, especially if you're building a pretty vanilla web app. Since Next takes care of routing for you, the need for projects like this operating at huge scales is diminishing. I'm glad they still exist for teams that want/need to own the entire application stack, but there are benefits from the community standardizing too. At my job (dev consulting agency), we're about to embark on rebuilding an in-house framework onto Next.js to take advantage of the larger community tooling and to simplify onboarding of new hires. React Router has so far made it through 6 iterations, it wouldn't surprise me if v7 was some sort of drop-in plugin replacement within Next. It could open up some areas for more complex navigation requirements without some of the hacky workarounds you need in Next currently. Interesting times indeed!
- n42 5y agoNext's router is the only thing that holds me back from fully embracing it. It sucks that I have to give up every other awesome thing the framework offers when I have a project that does not fit with their router. Hoping something changed in the last year and someone can point me to a solution
- Griffinsauce 5y agoI'm curious: what specific problems are you running into?
- TranquilMarmot 5y agoThe author of react-query (one of my favorite libraries) also just released the beta of yet another router called React Location: https://react-location.tanstack.com/ https://react-location.tanstack.com/ I've used Reach Router in the past and it's also pretty nice, but I didn't see a reason to use it over React Router... https://reach.tech/router/ https://reach.tech/router/
- lloydatkinson 5y agoVue has an official router library, but react seems to have multiple popular routing libraries. Reinventing the wheel much?
- TranquilMarmot 5y agoI've definitely found it a little weird how React doesn't have a more official routing library, especially since they are all so similar. It feels like Next.js is taking over a lot of things that React _should_ have by default but doesn't. Which is fine, but Next.js is also a little too much for a lot of smaller projects I work on.
- bliteben 5y agoHow is anyone supposed to get a job if they don't promote their own fiefdom?
- vesuvianvenus 5y agoWow, another library (react-location) that shows TypeScript as its primary documentation language. And I see more and more jobs hiring for TypeScript developers. I see Microsoft's 3 E's campaign strongly in action with TypeScript. For those who care about Corporate Ethics, please review Microsoft's: https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguish https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis... For that reason, I refuse to touch TypeScript libraries-- out of sheer anti-corporate-oligarchy ethical conviction.
- jjeaff 5y ago
- throwaway4good 5y agoI am I the only who finds this library a wee bit overengineered?
- nsonha 5y agowhat part is over-engineered?
- throwaway4good 5y agoAll of it. Think of it this way. How would you do routing in a React app from scratch: 1. Listen for changes in the URL. 2. Parse the new URL into a routing object. 3. Pass the routing object down through the component hierarchy. You can do that in maybe 5-10 lines of straightforward code.
- machiaweliczny 5y agoIs routing so hard you have to revamp it 6 times?
- vbg 5y agoI still feel resentful about how earlier versions of react router had massive breaking changes effectively completely changing it, provided no documentation and no help at all even understanding the new thing let alone explaining how to upgrade. To be fair I believe I once read they now don’t do that but it was truly scarring to naively update to the newest version thinking my app would need a few tweaks to get going again, when in fact big chunks needed rewriting, with zero help from the developers.
- dbbk 5y agoThat's the definition of a major version change though...
- yladiz 5y agoA major version change may (or may not) have some breaking changes, but most good libraries have migration guides and documentation on how to upgrade. Presumably the parent comment was annoyed that the breaking changes also included no docs or guides.
- vbg 5y agoFalse.
- btown 5y agoTheoretically yes, but if you think of the metric of % of library-interacting lines of code an average library user needs to change to upgrade, React Router has been a huge outlier compared to other libraries in the React ecosystem. Your routing components would change completely. And the maintainers saw no problem with this.
- bern4444 5y agoThe authors of React Router are developing a framework for React called remix[0]. It's not available yet, but it will be soon and it will be open source. Remix will certainly use react-router and I expect it to be similar to NextJS but better. My expectation is Remix will blow NextJS out of the water and become the defacto starting point like how NextJS is today. [0] remix.run
- conradludgate 5y agoI was working on a project recently combining ViteJS and React Router to make a NextJS alternative. Mostly so that I have more control about where I host it and not so Lambda/Vercel optimised. I don't really see how you could "blow NextJS out of the water" though. As a concept, NextJS nails it with the simple directory structure, api endpoints, a nice mix of server side and client side rendering. There's not much else I'd want from a web framework feature wise.
- conradludgate 5y agohttps://github.com/conradludgate/vite-react-ssr-next https://github.com/conradludgate/vite-react-ssr-next here's my project if anyone is interested. It kinda sucks at the moment though so definitely don't use it, but hopefully it might inspire someone
- jimrandomh 5y agoI really don't think react-router provides enough functionality to justify the amount of churn it's generating. URL routing is not complicated and not hard. After getting dragged through a v3->v4 upgrade by a library we use, I put in a lint rule forcing all usages of it to go through a wrapper.