Hacker News new | ask | show | jobs
by ivansavz 3430 days ago
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!

3 comments

Difference is the API. React Router is a 100% declarative components, rather than configs and imperative actions.
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 do both of those things as well and is fully supported by react-native core contributors.

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)
Difference in opinions about what could be accomplished via react-router vs what native paradigms needed to be crafted.
Do you have a list of these native paradigms anywhere?
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.

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â„¢

Navigating isn't more complex in native apps, and I didn't mean to imply that. But navigation state may be deeper than flat sets of URIs: it may be a tree.

For example: your app may have a stack of modal screens, and each of those screens may have tabs or a stack, and there may be another tab or stack navigation within each of those. In React Navigation, each node can be a router that manages its own navigation state.