Using react router on one of my personal projects (~ 30k loc) was probably one of my largest regrets. At every turn it seemed designed to do the thing I wouldn’t expect, or have arbitrary restrictions that made my life tougher.<p>Some examples:<p>* there's no relative routes <a href="https://github.com/ReactTraining/react-router/issues/2172" rel="nofollow">https://github.com/ReactTraining/react-router/issues/2172</a><p>* there's no way to refresh the page <a href="https://github.com/ReactTraining/react-router/issues/1982" rel="nofollow">https://github.com/ReactTraining/react-router/issues/1982</a> ("that's your responsibility, not ours")<p>* The scroll position will stick when you navigate to a new route, causing you to need to create a custom component wrapper to manage scrolling <a href="https://github.com/ReactTraining/react-router/issues/3950" rel="nofollow">https://github.com/ReactTraining/react-router/issues/3950</a><p>* React router's <Link> do not allow you to link outside of the current site <a href="https://github.com/ReactTraining/react-router/issues/1147" rel="nofollow">https://github.com/ReactTraining/react-router/issues/1147</a> so you have to make an <a> in those cases. This doesn’t sound bad, but it’s particularly frustrating when dealing with dynamic or user generated content. Why can’t they handle this simple case?<p>* Navigating to the same page would not actually reload the page, it would just trigger a componentDidMount() on all components in the page again, which led me to have a lot of bugs when I did some initialization in my constructor
I usually shudder when I see React Router major versions which usually result in hard breaks that takes hours to migrate existing code bases to, so I'm pleasantly surprised to see:<p>> v5 is fully backwards compatible with 4.x<p>It appears the major version bump was due to package configuration changes instead of major API code changes.
We migrated from React Router to Reach Router (<a href="https://reach.tech/router" rel="nofollow">https://reach.tech/router</a>) and found it to be better in a few ways:<p>* Built-in focus management.<p>* Smaller library size.<p>* Implicit route matching that Just Works.<p>* More comprehensive docs with live examples.<p>Migration was easy. Highly recommended.
react-router depends on the ReactTraining/history package for browser navigation support.<p>On 10 June 2017, an mind-bogglingly ill-conceived pull request[1] was merged, which causes <i>invalid</i> URLs to be pushed to the browser history, breaking the back button and page refresh in many scenarios.<p>Ever since, users have practically been begging the maintainer to fix the bug[2] and implementing hacky workarounds[3].<p>In a twist of irony, the contributor who originally introduced the bug has:<p>a) switched their own competing router package to a different history implementation[4]<p>b) argued that fixing the bug (which was introduced in a patch release) would require a major version bump, implying it would be better to let it remain broken[5].<p>I concede that the software is open source, and nobody is entitled to make any demands of the maintainers. Nevertheless, I pity the countless end-users who are left wondering why the most basic functionality of their web browsers is broken.<p>[1]: <a href="https://github.com/ReactTraining/history/pull/465" rel="nofollow">https://github.com/ReactTraining/history/pull/465</a><p>[2]: <a href="https://github.com/ReactTraining/history/issues/505" rel="nofollow">https://github.com/ReactTraining/history/issues/505</a><p>[3]: <a href="https://github.com/elastic/kibana/pull/32365" rel="nofollow">https://github.com/elastic/kibana/pull/32365</a><p>[4]: <a href="https://github.com/pshrmn/curi/commit/e850bcd9297398653a79b903f35818cb2df7738c" rel="nofollow">https://github.com/pshrmn/curi/commit/e850bcd9297398653a79b9...</a><p>[5]: <a href="https://github.com/ReactTraining/history/pull/656" rel="nofollow">https://github.com/ReactTraining/history/pull/656</a>
I migrated away from react-router because from v3 to v4 broke everything that made sense. Things became wildly more complicated.<p>I'm now extremely happy with my new router of choice router5 (not to be confused with React Router 5) <a href="https://router5.js.org" rel="nofollow">https://router5.js.org</a>.
Hi reader unfamiliar with React Router! Just a heads up - these comments are not representative of typical React Router users. I work with React Router every day, and my co-workers and I love it.<p>Something about HN gives people license to air all of their nitpick grievances, and make it seem like SUcH A bIg DEaL OmG WorST LiBRarY EVArR!11<p>To the authors, maintainers, and contributors: Thank you for making the ecosystem better. It makes our work easier.
Interesting to see the reason they had to do a major version bump, because of the usage of ^ in their internal dependencies meaning that you could get a mismatch between versions of the two internal sub packages react-router and react-router-dom.<p>The solution? Pinning the version to an exact number.<p>I <i>always</i> do this now as a policy, for everything, even when I'm using lockfiles though it shouldn't strictly be necessary, because I've been burned by ^ too many times. There's this ideal world expectation of ^ that it will magically give you upgrades for free without changes in behaviour, but breaking changes in behaviour occur <i>all the time</i> in minor and patch version updates in real world npm.<p>I think this is an intractable problem - mistakes will always be made, even when people try really hard, and over 100s of dependencies in a project you're therefore quite likely to see these mistakes fairly regularly.
I've never been a fan of React Router (mostly I don't get why defining routes with components is a good thing) and have been pleasantly surprised with how well Curi (<a href="https://curi.js.org/" rel="nofollow">https://curi.js.org/</a>) works. It's nice to see it's not completely tied to a JS framework.
I recently implemented home grown routing in one of my apps - and was surpised to see that it was about 30 lines of simple code. You don't really need to tie yourself to a third party lib and risk future upgrades. Wrote about it here: <a href="https://medium.com/p/9e2c7b036b0" rel="nofollow">https://medium.com/p/9e2c7b036b0</a>
I had nothing but trouble whenever I used React Router. For example, sometimes paths would be appended to the URL instead of replacing it, making it grow indefinitely, and it wasn't obvious why.<p>There were two API rewrites in a short space of time and it was extremely frustrating, especially since it seemed almost compulsory to be experienced with React Router (along with Redux) to be taken seriously by recruiters.<p>For my own projects, I started using page.js years ago and haven't looked back.<p><a href="https://github.com/visionmedia/page.js" rel="nofollow">https://github.com/visionmedia/page.js</a>
Author here.<p>One more time for those in the back:<p>v0.x > v1
Breaking changes<p>v1 > v2 > v3
a couple obscure breaking changes, but practically none<p><i>18 months pass</i><p>v3 > v4
New, composable design, basically a new project<p>v3 still maintained, 3.5 years no changes.
v4 2 years, no changes.<p>v4 -> v5 was supposed to be 4.4, but an internal dependency '^' got us, so best choice was version bump to prevent problems.
I'm surprised to see so many negative comments about react-router here. I've used react-router v4 in a half dozen projects without significant issues, and I think the API is pretty flexible and easy to work with. I'm glad to see the React Training folks continue working on it.
As someone who works with both React and VueJS on a daily basis, I find Vue Router to be much MUCH easier to work with, well documented and is really straightforward. Most importantly - It's an official package from VueJS core team and not a third party, so it's pretty much worry-free.
Probably the least stressful major version bump I've seen. Props to the team for solving the 4.4.x problem and pushing this out. Took a few minutes to update and now everything is great!
May I take this opportunity to recommend found? It’s great: <a href="https://github.com/4Catalyzer/found" rel="nofollow">https://github.com/4Catalyzer/found</a>.
Here's an alternative which is being actively maintained: <a href="https://github.com/frontarm/navi" rel="nofollow">https://github.com/frontarm/navi</a>
So many negative comments in here.
Just wanted to let the maintainers know we use the library in multiple projects without issue and that we appreciate deeply the work that goes into it!
Anybody using ui-router? I used to use that one in angular and saw they have a react version now. But I'm not yet familiar enough with react to judge it.
Using React Component for routing has a benefit: Universal Routing, with all benefits of React inside the route itself (lifecycle, state, data fetching,...).
> There are no breaking changes in this release.<p>Nice, glad to see the project becoming more stable. Upgrading from v3 to v4 made us a lot problems...