Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency react-navigation to v4 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Jan 10, 2021

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
react-navigation 3.13.0 -> 4.4.4 age adoption passing confidence

Release Notes

react-navigation/react-navigation

v4.4.4

Compare Source

Note: Version bump only for package react-navigation

v4.4.3

Compare Source

Note: Version bump only for package react-navigation

v4.4.2

Compare Source

Note: Version bump only for package react-navigation

v4.4.1

Compare Source

Note: Version bump only for package react-navigation

v4.4.0

Compare Source

Features
  • sync latest stack and upgrade typescript (454e05b)

v4.3.9

Compare Source

Bug Fixes
  • change old docUrl to new docUrl due v5 (e09906a)

v4.3.8

Compare Source

Note: Version bump only for package react-navigation

v4.3.7

Compare Source

Note: Version bump only for package react-navigation

v4.3.6

Compare Source

Note: Version bump only for package react-navigation

v4.3.5

Compare Source

Note: Version bump only for package react-navigation

v4.3.4

Compare Source

Note: Version bump only for package react-navigation

v4.3.3

Compare Source

Note: Version bump only for package react-navigation

v4.3.2

Compare Source

Note: Version bump only for package react-navigation

v4.3.1

Compare Source

Note: Version bump only for package react-navigation

v4.3.0

Compare Source

Features
  • add prune option to pop action to match v5 behaviour (5927f42)

v4.2.2

Compare Source

Bug Fixes
  • fix typescript errors in the definition file (3bb2c19)

v4.2.1

Compare Source

Note: Version bump only for package react-navigation

v4.2.0

Compare Source

4.2.0 (2020-02-24)

Bug Fixes
Features
Reverts

v4.1.1: Release 4.1.1

Compare Source

Bug Fixes
  • don't use declare module for type definitions (0fb81cf)
  • make sure index.js is common js (4cff366)

v4.1.0: Release 4.1.0

Compare Source

Bug Fixes
Features

v4.0.10: Release 4.0.10

Compare Source

Changes
  • remove flow definition libdef from repo, use flow-typed instead (94d6cca)
Bug Fixes
  • update link to docs page from deprecation messages (188bd33)

v4.0.9: Release 4.0.9

Compare Source

Bug Fixes

v4.0.8: Release 4.0.8

Compare Source

Bug Fixes

v4.0.7: Release 4.0.7

Compare Source

Bug Fixes
  • accept type parameter for screenProps (5c13cea)

v4.0.6: Release 4.0.6

Compare Source

Bug Fixes

v4.0.5: Release 4.0.5

Compare Source

Bug Fixes
  • update react-navigation/core (951afa5)

v4.0.4: Release 4.0.4

Compare Source

Bug Fixes
  • improve type definitions (e3d2ce1)

v4.0.3: Release 4.0.3

Compare Source

Bug Fixes

v4.0.2: Release 4.0.2

Compare Source

Bug Fixes
  • fix typo in definitions (e7028ce)

v4.0.1: Release 4.0.1

Compare Source

Bug Fixes

v4.0.0: Release 4.0.0

Compare Source

In this release, we've extracted out the navigators to separate packages to make it easier to maintain and release updates faster. You can follow the guide below to upgrade your projects.

Upgrading

NOTE: Before making these changes, we recommend you to commit all local changes to git so you can revert back to a good state if something goes wrong with the upgrade.

Install the new packages

First, we need to install the react-navigation package along with the various navigators. If you don't use some of these navigators, you can omit them.

To install them, run:

yarn add react-navigation react-navigation-stack@^1.7.3 react-navigation-tabs@^1.2.0 react-navigation-drawer@^1.4.0

This will install the versions compatible with your code if you were using [email protected], so you wouldn't need any more changes beyond changing the imports.

NOTE: If you have @react-navigation/core or @react-navigation/native in your package.json, please remove them and change the imports to import from react-navigation package instead.

Changing your code

Then change any imports for stack, tabs or drawer to import from the above packages instead of react-navigation.

- import { createAppContainer, createStackNavigator } from 'react-navigation';
+ import { createAppContainer } from 'react-navigation';
+ import { createStackNavigator } from 'react-navigation-stack';

The following imports need to be changed to import from react-navigation-stack:

  • createStackNavigator
  • StackGestureContext
  • Transitioner
  • StackView
  • StackViewCard
  • StackViewTransitionConfigs
  • Header
  • HeaderTitle
  • HeaderBackButton
  • HeaderStyleInterpolator

The following imports need to be changed to import from react-navigation-tabs:

  • createBottomTabNavigator
  • createMaterialTopTabNavigator
  • BottomTabBar
  • MaterialTopTabBar

The following imports need to be changed to import from react-navigation-drawer:

  • createDrawerNavigator
  • DrawerGestureContext
  • DrawerRouter
  • DrawerActions
  • DrawerView
  • DrawerNavigatorItems
  • DrawerSidebar
Upgrading navigators (optional)

You don't need to upgrade the navigators to their latest version when upgrading to [email protected]. You can upgrade them separately later as per your convenience.

NOTE: We recommend to do these changes in a separate commit so you can revert back to a good state if something goes wrong with the upgrade.

Installing dependencies

The latest drawer and tabs depend on react-native-gesture-handler and react-native-reanimated. If you already have these libraries installed and at the latest version, you are done here! Otherwise, read on for installation instructions for these dependencies.

Installing dependencies into an Expo managed project

In your project directory, run the following:

expo install react-native-gesture-handler react-native-reanimated

This will install versions of these libraries that are compatible.

Installing dependencies into a bare React Native project

In your project directory, run yarn add react-native-reanimated react-native-gesture-handler react-native-screens.

Next, we need to link these libraries. The steps depends on your React Native version:

  • React Native 0.60 and higher

    On newer versions of React Native, linking is automatic.

    To complete the linking on iOS, make sure you have Cocoapods installed. Then run:

    cd ios
    pod install
    cd ..
  • React Native 0.59 and lower

    If you're on an older React Native version, you need to manually link the dependencies. To do that, run:

    react-native link react-native-reanimated
    react-native link react-native-gesture-handler

To finalize installation of react-native-gesture-handler for Android, make the following modifications to MainActivity.java:

package com.reactnavigation.example;

import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

  @​Override
  protected String getMainComponentName() {
    return "Example";
  }

+  @​Override
+  protected ReactActivityDelegate createReactActivityDelegate() {
+    return new ReactActivityDelegate(this, getMainComponentName()) {
+      @​Override
+      protected ReactRootView createRootView() {
+       return new RNGestureHandlerEnabledRootView(MainActivity.this);
+      }
+    };
+  }
}
Upgrading packages

To upgrade react-navigation-tabs, run:

yarn add react-navigation-tabs

For list of breaking changes, refer to the release notes.

To upgrade react-navigation-drawer, run:

yarn add react-navigation-drawer

For list of breaking changes, refer to the release notes.

More info

For more info and release notes, please refer to the individual packages:

TypeScript

If you're using TypeScript, you'll also need to upgrade the navigators to the latest version following the previous section. Since the navigators have been extracted out, navigator specific types have been removed from the main package. You'll need to update the types accordingly:

  • Replace NavigationScreenProp with:
    • NavigationSwitchProp for createSwitchNavigator from react-navigation
    • NavigationStackProp for createStackNavigator from react-navigation-stack
    • NavigationTabProp for createBottomTabNavigator and createMaterialTopTabNavigator from react-navigation-tabs
    • NavigationDrawerProp for createDrawerNavigator from react-navigation-drawer
  • Replace NavigationScreenProps with:
    • NavigationSwitchScreenProps for createSwitchNavigator from react-navigation
    • NavigationStackScreenProps for createStackNavigator from react-navigation-stack
    • NavigationTabScreenProps for createBottomTabNavigator and createMaterialTopTabNavigator from react-navigation-tabs
    • NavigationDrawerScreenProps for createDrawerNavigator from react-navigation-drawer
  • Replace NavigationScreenOptions with:
    • NavigationStackOptions for createStackNavigator from react-navigation-stack
    • NavigationBottomTabOptions for createBottomTabNavigator from react-navigation-tabs
    • NavigationMaterialTabOptions for createMaterialTopTabNavigator from react-navigation-tabs
    • NavigationDrawerOptions for createDrawerNavigator from react-navigation-drawer
  • Replace NavigationScreenComponent with:
    • NavigationSwitchScreenComponent for createSwitchNavigator from react-navigation
    • NavigationStackScreenComponent for createStackNavigator from react-navigation-stack
    • NavigationBottomTabScreenComponent for createBottomTabNavigator from react-navigation-tabs
    • NavigationMaterialTabScreenComponent for createMaterialTopTabNavigator from react-navigation-tabs
    • NavigationDrawerScreenComponent for createDrawerNavigator from react-navigation-drawer

See the docs for more details: https://reactnavigation.org/docs/en/typescript.html

TypeScript support is still a work in progress, so please open an issue in the respective package's repo if you're facing a problem.

Documentation

Updated documentation can be found on the official website.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot force-pushed the renovate/major-react-navigation-monorepo branch from c33bba8 to 7f53a85 Compare April 26, 2021 16:19
@renovate
Copy link
Author

renovate bot commented Mar 24, 2023

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

⚠️ Warning: custom changes will be lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant