Live data from Hacker News

React Router v5

reacttraining.com

81–90 of 90 posts

Re: React Router v5

#81
Author here.

One more time for those in the back:

v0.x > v1 Breaking changes

v1 > v2 > v3 a couple obscure breaking changes, but practically none

18 months pass

v3 > v4 New, composable design, basically a new project

v3 still maintained, 3.5 years no changes. v4 2 years, no changes.

v4 -> v5 was supposed to be 4.4, but an internal dependency '^' got us, so best choice was version bump to prevent problems.

Re: React Router v5

#82
post #18
post #13

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. Some examples: * there's no relative routes https://github.com/ReactTraining/react-router/issues/2172 * there's no way to refresh the page https://github.com/ReactTraining/react-router/issues/…

Yup. I only use react-router when I have to (work). My other projects I always roll my own. A typical html5 push router can be really small. I don’t reinvent the wheel normally but routing is hugely overcomplicated in the react ecosystem.

I use preact in some of my projects and its router ("preact-router") actually does what it should:

- has an easy callback

- instead of you can just use and it works for internal and external links

- routes are per default "exact", so "/profile" doesn't match "/profile/settings"

So much better, highly recommended. You probably need to alias "preact" to "react" in your webpack settings though.

Re: React Router v5

#83
Using React Component for routing has a benefit: Universal Routing, with all benefits of React inside the route itself (lifecycle, state, data fetching,...).

Re: React Router v5

#84

I migrated away from react-router because from v3 to v4 broke everything that made sense. Things became wildly more complicated. I'm now extremely happy with my new router of choice router5 (not to be confused with React Router 5) https://router5.js.org .

What I dislike most about React Router is how it pollutes rendering logic. They say it makes routing declarative. A switch statement is not declarative.

Re: React Router v5

#85

Author here. One more time for those in the back: v0.x > v1 Breaking changes v1 > v2 > v3 a couple obscure breaking changes, but practically none 18 months pass v3 > v4 New, composable design, basically a new project v3 still maintained, 3.5 years no changes. v4 2 years, no changes. v4 -> v5 was supposed to be 4.4, but an internal dependency '^' got us, so best choice was version bump to prevent problems.

I think it was the fact that v3 to 4 was "basically a new project" with a new paradigm that earnt the reputation for breaking changes but then React Router is such a marketable name I can see why you'd be reluctant to spin off a new project.

Re: React Router v5

#86
post #13

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. Some examples: * there's no relative routes https://github.com/ReactTraining/react-router/issues/2172 * there's no way to refresh the page https://github.com/ReactTraining/react-router/issues/…

I've been using the `connected-react-router` wrapper for redux with react-router, and it's been very nice to use... though my router component is getting really big at this point... but still understandable.

Re: React Router v5

#87
post #38
post #28

Earlier quoted context omitted.

> It is most definitely not a one-liner. const LinkWrapper = ({to, ...rest}) => to.startsWith(window.location.origin) ? : ; > So do it for me. There’s no reason a routing library should break default behavior. It's not default behavior for a client side router. Making it automatically scroll to the top would save you a few lines of code while creating a monumental headache for those who need it to retain the scroll p…

This has a number of bugs. Links don’t have to start with window.location.origin, they can just start with /. You didn’t pass in ...rest into the a tag, but oh did you know that the props of a are not the same type as the props to Link? They’re not - so even if you did that it wouldn’t have worked. Oh, and don’t forget to handle “javascript:” prefixed links - those are valid too. Oh and good luck getting this to type…

I understand the frustration.. that said, if you use a `javascript:` link in a modern web application, you deserve what you get (garbage).

Re: React Router v5

#88
post #53

Earlier quoted context omitted.

> there's no relative routes https://github.com/ReactTraining/react-router/issues/2172 I've been managing "relative" routes by just using `match.path` and `match.url` from the previous route. Works fine. function Parent(props) { return ( Child ); } function Child({match}) { return ( Grandchild ) }

I also do this - 4 layers deep at times - and it works great. IMHO it's one of the more clever bits of react-router.

Yup. My "top level routes" only have 3 paths, and everything goes from there. Thinking about routes just like components is really fantastic for react, and I don't miss having a giant central router even a little bit.

Re: React Router v5

#89
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!

Re: React Router v5

#90
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.
Post reply on HN