Live data from Hacker News

React Router: Declarative Routing for React

reacttraining.com

21–30 of 68 posts

Re: React Router: Declarative Routing for React

#21
The new API looks quite a bit like the API we've been running in React-Router-Component since 2014 (https://github.com/STRML/react-router-component).

Of course, RRC is not as battle-tested as React-Router; it's more of a "works for us" project I took over from @andreypopp as we had already committed to the router before React-Router became stable. And given the many backcompat-breaking changes to React-Router, it seems to have been a good idea.

React-Router does great work though; RRC doesn't even pretend to do React Native and the Environment selection we do have (pathname, pushstate, etc) isn't quite as nice. RRC also can't do some of the more interesting features, like Recursive Routes. All of the children of the router have to be `` objects.

Edit: React-Router's docs are awesome! Nice work @ryanflorence.

Re: React Router: Declarative Routing for React

#22
post #21

The new API looks quite a bit like the API we've been running in React-Router-Component since 2014 ( https://github.com/STRML/react-router-component ). Of course, RRC is not as battle-tested as React-Router; it's more of a "works for us" project I took over from @andreypopp as we had already committed to the router before React-Router became stable. And given the many backcompat-breaking changes to React-Router, it s…

[deleted]

Re: React Router: Declarative Routing for React

#23

Could someone comment about how this compares with other projects like: https://github.com/react-community/react-navigation and https://github.com/facebook/react-native/blob/master/docs/Us... ? Awesome docs, BTW!

react-navigation will supersede all existing navigator solutions in React Native core (Navigator/NavigationExperimental). React Router v4 is building a react-native integration to show that it is capable of working on Native. It's centered around URLs so it's attempting to make Deep Linking into your application easier, as well potentially re-using the same navigation on the web. That being said react-navigation can…

Out of curiosity, why was the decision made to build a completely new router (react-navigation) vs collaborating on better native support to the existing react-router? (which is working towards that anyway)

Re: React Router: Declarative Routing for React

#24
post #9

The docs are super good. I love the "embedded browser" that shows how it works. Shameless self plug: our book [1] has a whole chapter on Routing in React with this new v4 router. After you've finished reading the docs, if you want a tutorial style walk-through of this router v4, we build a Spotify-type clone over the course of 75+ pages. [1]: https://www.fullstackreact.com

FWIW, while I haven't read it myself I've only heard great things about Fullstack React! Would recommend based on recommendations I've gotten.

Re: React Router: Declarative Routing for React

#25

Could someone comment about how this compares with other projects like: https://github.com/react-community/react-navigation and https://github.com/facebook/react-native/blob/master/docs/Us... ? Awesome docs, BTW!

From my perspective, React Navigation primarily differs from React Router in a few ways:

1) In RR, nav state is the URI. Because mobile nav state is complex, React Navigation treats URIs as actions to modify a more complex navigation state

2) RR uses React Components for navigation logic. In React Navigation, the isolated nav logic is statically available, (without rendering).

3) React Navigation is composable, so navigators can be configured to delegate navigation logic to child routers.

Re: React Router: Declarative Routing for React

#26
post #13

The website is broken on mobile - elements overlap and content is not visible.

Slightly off topic, but do you find that docs really need to be mobile friendly? I'd personally rather the developer focuses on the actual project and all those concerns rather than a perfect responsive docs page. Esp when assuming most of these docs are eventually translated into markdown on github which are then mobile friendly.

I tend to do exploration on my phone when I have downtime while being out and about. Mobile friendly docs are a sure way to keep my attention on your project if I stumble upon it during these times.

Of course, I do plenty of research from my desktop as well, so if it's a choice between getting a new release out on time or having a perfect mobile experience, I'd suggest library authors prefer getting timely releases out myself.

Re: React Router: Declarative Routing for React

#27
post #7

I look forward to the next API revision. Churning your API frequently turns me off as a developer who would rather not be deprecated out the gate.

I look forward to the day where people can improve upon their project based on gained knowledge without passive aggressive comments about the lack of back compat.

This is how software improves. You are not forced to upgrade to the next version.

Re: React Router: Declarative Routing for React

#28
post #21

The new API looks quite a bit like the API we've been running in React-Router-Component since 2014 ( https://github.com/STRML/react-router-component ). Of course, RRC is not as battle-tested as React-Router; it's more of a "works for us" project I took over from @andreypopp as we had already committed to the router before React-Router became stable. And given the many backcompat-breaking changes to React-Router, it s…

> backcompat-breaking changes to React-Router

We had breaking changes from 0.13 to 1.0.

Then complete BC from 1.0 to 2.0

That's two years, one breaking upgrade.

Don't confuse a libs "changing API" with "people use the development branch as stable".

Re: React Router: Declarative Routing for React

#29
post #25

Could someone comment about how this compares with other projects like: https://github.com/react-community/react-navigation and https://github.com/facebook/react-native/blob/master/docs/Us... ? Awesome docs, BTW!

From my perspective, React Navigation primarily differs from React Router in a few ways: 1) In RR, nav state is the URI. Because mobile nav state is complex, React Navigation treats URIs as actions to modify a more complex navigation state 2) RR uses React Components for navigation logic. In React Navigation, the isolated nav logic is statically available, (without rendering). 3) React Navigation is composable, so na…

1) Not sure why navigating is "more complex on native". The platform the code runs on has nothing to do with the way the user interacts with the page. Complex navigation state is represented as one or many stacks of URIs.

2) In React Router you can have a statically available route config. This is React. Make an array then map it to render.

3) React Router is all components, so it composes exactly like the rest of your app. No new API to learn. It's Just React™

Re: React Router: Declarative Routing for React

#30
post #13

The website is broken on mobile - elements overlap and content is not visible.

Slightly off topic, but do you find that docs really need to be mobile friendly? I'd personally rather the developer focuses on the actual project and all those concerns rather than a perfect responsive docs page. Esp when assuming most of these docs are eventually translated into markdown on github which are then mobile friendly.

Absolutely, lets you study docs anywhere. Also looks low quality if a site breaks on mobile.
Post reply on HN