Skip to content

React Navigation 4.0 moves navigators into separate packages

updated

React Navigation 4.0 has been released, and the navigators are no longer included in the react-navigation package. Documentation for the new version is live at reactnavigation.org, with the v3 docs still available.

What changed

The navigators had already been maintained in their own packages for some time, and developers could install those packages directly. However, react-navigation continued to bundle them. According to the team, that arrangement meant any significant navigator update required a major version bump of react-navigation itself.

With 4.0, navigators must be installed from their respective packages:

  • createStackNavigator - react-navigation-stack
  • createBottomTabNavigator, createMaterialTopTabNavigator - react-navigation-tabs
  • createDrawerNavigator - react-navigation-drawer

Each of these packages can now be updated on its own schedule, without affecting projects that do not use a given navigator.

The latest versions of the drawer and tab navigators use react-native-reanimated to animate gestures, which the team says makes their animations more performant. These improvements have been available in react-navigation-drawer and react-navigation-tabs for several months, but the maintainers avoided pulling them into react-navigation so as not to force every user to update.

TypeScript users

Navigator-specific TypeScript types have also been removed from the main package. The release notes list the replacement types. The team asks anyone who still runs into type problems after following those notes to open an issue.

Upgrading

Upgrade instructions are in the 4.0 release notes, and the team asks that problems be reported on the react-navigation issue tracker.

Source: reactnavigation.org