Hacker News new | ask | show | jobs
by evv 3432 days ago
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 comments

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.