Skip to content

Commit 95cf437

Browse files
committed
Add a table of breaking changes to upgrade guide
1 parent 08d2a81 commit 95cf437

File tree

2 files changed

+104
-15
lines changed

2 files changed

+104
-15
lines changed

blog/2021-03-12-react-navigation-6.0-next.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ We'll share few highlights of the release in this blog post. If you're looking f
2727

2828
## Try it out
2929

30-
The new versions are published under `next` tag on [npm](https://npmjs.org). So if you'd like to try it out, add `@next` to the package, you're installing. For example:
30+
If you'd like to try it out, add `@^6.x` to the package, you're installing. For example:
3131

3232
```sh npm2yarn
33-
npm install @react-navigation/native@next @react-navigation/stack@next
33+
npm install @react-navigation/native@^6.x @react-navigation/stack@^6.x
3434
```
3535

3636
## What's next?

versioned_docs/version-6.x/upgrading-from-5.x.md

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,64 @@ sidebar_label: Upgrading from 5.x
66

77
React Navigation 6 keeps the same API as React Navigation 5, however there are some breaking changes to make the API more consistent, more flexible and less confusing.
88

9-
This guide lists all the changes that you need to keep in mind when upgrading.
9+
This guide lists all the changes and new features that you need to keep in mind when upgrading.
10+
11+
## Table of breaking changes
12+
13+
The upgrade guide includes both new features as well as breaking changes across all packages. The table below is for your convenience to quickly find the list of all the breaking changes.
14+
15+
- General Changes: These changes affect all React Navigation users.
16+
17+
- [Older versions of some libraries are no longer supported](#older-versions-of-some-libraries-are-no-longer-supported)
18+
- [Params are now overwritten on navigation instead of merging](#params-are-now-overwritten-on-navigation-instead-of-merging)
19+
- [Dropped `dangerously` from `dangerouslyGetParent` and `dangerouslyGetState`](#dropped-dangerously-from-dangerouslygetparent-and-dangerouslygetstate)
20+
- [No more `state` property on the `route` prop](#no-more-state-property-on-the-route-prop)
21+
- [Linking configuration is now stricter](#linking-configuration-is-now-stricter)
22+
- [Dropped useLinking hook](#dropped-uselinking-hook)
23+
- [Stricter types for TypeScript](#stricter-types-for-typescript)
24+
25+
- Stack Navigator: These changes affect users of `@react-navigation/stack` package.
26+
27+
- [`keyboardHandlingEnabled` is moved to options](#keyboardhandlingenabled-is-moved-to-options)
28+
- [`mode="modal"` is removed in favor of `presentation: 'modal'`](#modemodal-is-removed-in-favor-of-presentation-modal)
29+
- [`headerMode="none"` is removed in favor of `headerShown: false`](#headermodenone-is-removed-in-favor-of-headershown-false)
30+
- [`headerMode` is moved to options](#headermode-is-moved-to-options)
31+
- [Custom header now uses `'headerMode: screen'` by default](#custom-header-now-uses-headermode-screen-by-default)
32+
- [Props passed to custom header are streamlined](#props-passed-to-custom-header-are-streamlined)
33+
- [Header now uses flexbox](#header-now-uses-flexbox)
34+
- [The `gestureResponseDistance` option is now a number instead of an object](#the-gestureresponsedistance-option-is-now-a-number-instead-of-an-object)
35+
- [Some exports are now moved to the element library](#some-exports-are-now-moved-to-the-element-library)
36+
37+
- Bottom Tab Navigator: These changes affect users of `@react-navigation/bottom-tabs` package.
38+
39+
- [A header is shown by default in tab screens](#a-header-is-shown-by-default-in-tab-screens)
40+
- [The `tabBarOptions` prop is removed in favor of more flexible `options` for bottom tabs](#the-tabbaroptions-prop-is-removed-in-favor-of-more-flexible-options-for-bottom-tabs)
41+
- [The `tabBarVisible` option is no longer present](#the-tabbarvisible-option-is-no-longer-present)
42+
- [The `lazy` prop is moved to `lazy` option for per-screen configuration for bottom tabs](#the-lazy-prop-is-moved-to-lazy-option-for-per-screen-configuration-for-bottom-tabs)
43+
- [The default value for `backBehavior` is now `firstRoute` for bottom tabs](#the-default-value-for-backbehavior-is-now-firstroute-for-bottom-tabs)
44+
45+
- Material Top Tab Navigator: These changes affect users of `@react-navigation/material-top-tabs` package.
46+
47+
- [Material Top Tabs now uses `ViewPager` instead of Reanimated and Gesture Handler](#drawer-now-uses-viewpager-instead-of-reanimated-and-gesture-handler)
48+
- [The `tabBarOptions` prop is removed in favor of more flexible `options` for material top tabs](#the-tabbaroptions-prop-is-removed-in-favor-of-more-flexible-options-for-material-top-tabs)
49+
- [The `lazy` prop is moved to `lazy` option for per-screen configuration for material top tabs](#the-lazy-prop-is-moved-to-lazy-option-for-per-screen-configuration-for-material-top-tabs)
50+
- [The `lazyPlaceholder` prop is moved to `lazyPlaceholder` option for per-screen configuration for material top tabs](#the-lazyplaceholder-prop-is-moved-to-lazyplaceholder-option-for-per-screen-configuration-for-material-top-tabs)
51+
- [The default value for backBehavior is now firstRoute for material top tabs](#the-default-value-for-backbehavior-is-now-firstroute-for-material-top-tabs)
52+
53+
- Material Bottom Tab Navigator: These changes affect users of `@react-navigation/material-bottom-tabs` package.
54+
55+
- [Material Bottom Tabs now uses `react-native-safe-area-context` to apply safe area insets](#material-bottom-tabs-now-uses-react-native-safe-area-context-to-apply-safe-area-insets)
56+
- [The default value for `backBehavior` is now `firstRoute` for material bottom tabs](#the-default-value-for-backbehavior-is-now-firstroute-for-material-bottom-tabs)
57+
58+
- Drawer Navigator: These changes affect users of `@react-navigation/drawer` package.
59+
60+
- [A header is shown by default in drawer screens](#a-header-is-shown-by-default-in-drawer-screens)
61+
- [Slide animation is now default on iOS](#slide-animation-is-now-default-on-ios)
62+
- [Drawer status is now a string instead of a boolean](#drawer-status-is-now-a-string-instead-of-a-boolean)
63+
- [Drawer no longer emits `drawerOpen` and `drawerClose` events](#drawer-no-longer-emits-draweropen-and-drawerclose-events)
64+
- [The `drawerContentOptions` prop is removed in favor of more flexible `options` for drawer](#the-drawercontentoptions-prop-is-now-more-flexible-by-moving-to-options-for-drawer)
65+
- [The `lazy` prop is moved to `lazy` option for per-screen configuration for drawer](#the-lazy-prop-is-moved-to-lazy-option-for-per-screen-configuration-for-bottom-tabs)
66+
- [The default value for `backBehavior` is now `firstRoute` for drawer](#the-default-value-for-backbehavior-is-now-firstroute-for-drawer)
1067

1168
## General changes
1269

@@ -183,7 +240,13 @@ For example, you can use it for a bunch of regular screen and a bunch of modal s
183240
</Stack.Navigator>
184241
```
185242
186-
See [`Group``](group.md) docs for more details.
243+
See [`Group`](group.md) docs for more details.
244+
245+
### New `screenListeners` prop for navigators similar to `screenOptions`
246+
247+
It's now possible to add listeners for all of the screens in a navigator by using the `screenListeners` prop. This can be useful to listen to things like `tabPress` for all screens, `state` change at the navigator level etc.
248+
249+
See docs for [Navigation Events](navigation-events.md#screenlisteners-prop-on-the-navigator) for more details.
187250

188251
### New hook and helper for creating container ref
189252

@@ -197,7 +260,9 @@ Earlier, `useNavigation`, `Link`, `useLinkProps` etc. could only be used inside
197260

198261
### Stricter types for TypeScript
199262

200-
The type definitions are not stricter, which makes it easier to catch errors earlier by minimizing unsafe types. For example, `useNavigation` now throws an error if you don't specify a type. You can handle this by annotating it, or for an easier way, specify a type for root navigator which will be used for all usage of `useNavigation`.
263+
The type definitions are not stricter, which makes it easier to catch errors earlier by minimizing unsafe types. For example, `useNavigation` now shows a type error if you don't specify a type.
264+
265+
You can handle this by [annotating it](typescript.md#annotating-usenavigation), or for an easier way, [specify a type for root navigator](typescript.md#specifying-default-types-for-usenavigation-link-ref-etc) which will be used for all usage of `useNavigation`.
201266
202267
### Ability to specify a type for root navigator when using TypeScript
203268
@@ -243,15 +308,19 @@ Previously, `keyboardHandlingEnabled` was a prop on the navigator, but now it ne
243308

244309
Now there is a new `presentation` option which allows you to customize whether a screen is a modal or not on a per screen basis.
245310

246-
In addition, to match the default behavior of iOS, now `presentation: 'modal'` shows the new presentation style modal introduced in iOS 13. It also adjusts things like status bar height in the header automatically that you had to do manually before.
311+
In addition, to match the default behavior of iOS, now `presentation: 'modal'` shows the new presentation style modal introduced in iOS 13. It also adjusts things like status bar height in the header automatically that you had to do manually before. In addition, the color of the statusbar content is automatically managed when the screen animates.
247312

248313
Previously Android didn't have any special animation for modals. But now there's a slide from bottom animation instead of the default animation.
249314

250315
If you don't want to use the new animations, you can change it to your liking using the [animation related options](stack-navigator.md#animations). To use the iOS modal animation from React Navigation 5, use `TransitionPresets.ModalSlideFromBottomIOS`.
251316
252317
In addition, a new `presentation: 'transparentModal'` option to make it easier to build transparent modals. See [transparent modals](stack-navigator.md#transparent-modals) docs for more details.
253318
254-
This also makes it possible to mix regular screens with modal screens in the same stack, since these options don't need to be applied to the whole screen anymore.
319+
### Better support for mixing different types of animations in a single stack
320+
321+
Previously, it was sometimes necessary to nest 2 different stack navigators for certain animations, for example: when we wanted to use modal presentation style and regular styles.
322+
323+
It is now possible to mix regular screens with modal screens in the same stack, since these options don't need to be applied to the whole screen anymore.
255324

256325
### `headerMode="none"` is removed in favor of `headerShown: false`
257326

@@ -279,6 +348,14 @@ Previously, `headerMode` was a prop on the navigator, but now it needs to be spe
279348
280349
The `headerMode` option supports 2 values: `screen` and `float`.
281350
351+
### Header is now taller in modals on iOS
352+
353+
The header is now 56dp tall in modals to match the native iOS style. If you are using the [`useHeaderHeight`](elements.md#use-header-height) hook to get the height of the header, then you won't need to change any code.
354+
355+
### The header height from hidden header is now ignored
356+
357+
Previously, the [`useHeaderHeight`](elements.md#use-header-height) hook returned `0` if the header was hidden in a Stack Navigator. Now it returns the height of the closes visible header instead.
358+
282359
### Custom header now uses 'headerMode: screen' by default
283360

284361
Previously it was necessary to specify `headerMode='screen'` or a custom animation manually when using a custom header. Even though this was mentioned in the docs, it has been tripped up many people.
@@ -299,6 +376,14 @@ The header elements were rendered using absolute positioning which didn't work w
299376
300377
Previously, the [`gestureResponseDistance`](stack-navigator.md#gestureresponsedistance) option took an object with `horizontal` and `vertical` properties. Now it takes a number which will be used as the horizontal or vertical value based on the [`gestureDirection`](stack-navigator.md#gesturedirection) option.
301378
379+
### The two finger back gesture on trackpads in iPad is now supported
380+
381+
On iPad, it's possible to use two fingers to perform the back gesture in native apps. It's now also possible in Stack Navigator.
382+
383+
### Fix accessibility on Web when `react-native-screens` wasn't enabled
384+
385+
Previously, unfocused screens were still accessible on Web even if `react-native-screens` was disabled. This is no longer the case. Note that this only works when animations are not enabled (this is the default on Web). Otherwise, you'd need to enable `react-native-screens` to make it work if you had it disabled.
386+
302387
### Some exports are now moved to the element library
303388
304389
The following exports now live in the elements library since they are no longer specific to the stack navigator:
@@ -324,6 +409,8 @@ npm install @react-navigation/native-stack
324409

325410
### Breaking changes
326411

412+
If you were importing `createNativeStackNavigator` from `react-native-screens/native-stack`, you need to keep the following changes in mind when migrating to `@react-navigation/native-stack` package:
413+
327414
#### Options
328415

329416
- `backButtonInCustomView` option is removed, it's now automatically set when necessary
@@ -367,7 +454,7 @@ To keep the previous behavior, you can use `headerShown: false` in `screenOption
367454

368455
Previously the tab bar in bottom tabs showed an empty area when no icon was specified. Now it shows a question mark to make it more obvious that the icon is missing.
369456

370-
### The `tabBarOptions` prop is now more flexible by moving to `options` for bottom tabs
457+
### The `tabBarOptions` prop is removed in favor of more flexible `options` for bottom tabs
371458

372459
The `tabBarOptions` prop was removed and the options from there were moved to screen's `options` instead. This makes them configurable on a per screen basis.
373460
@@ -388,7 +475,7 @@ The list of the options and their new name are follows:
388475
389476
The `adaptive` option is removed since you can already disable the automatic label positioning by specifying a `tabBarLabelPosition`.
390477
391-
To keep the same behavior as before, you can specify these in `screenOptions`.
478+
The old options will still keep working with a deprecation warning. To avoid the deprecation warning, move these to `screenOptions`.
392479
393480
### The `tabBarVisible` option is no longer present
394481
@@ -432,13 +519,13 @@ For bare React Native projects:
432519
npm install react-native-pager-view
433520
```
434521

435-
### It now uses `ViewPager` instead of Reanimated and Gesture Handler
522+
### Material Top Tabs now uses `ViewPager` instead of Reanimated and Gesture Handler
436523

437524
The `react-native-tab-view` dependency is upgraded to the latest version (3.x) which now uses [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view) instead of Reanimated and Gesture Handler. This will provide a native UX and also improve the performance.
438525

439526
See [release notes for `react-native-tab-view`](https://github.com/satya164/react-native-tab-view/releases/tag/v3.0.0) for more details.
440527

441-
### The `tabBarOptions` prop is now more flexible by moving to `options` for material top tabs
528+
### The `tabBarOptions` prop is removed in favor of more flexible `options` for material top tabs
442529

443530
Similar to bottom tabs, the `tabBarOptions` prop was removed and the options from there were moved to screen's `options` instead.
444531
@@ -461,7 +548,7 @@ The list of the options and their new name are follows:
461548
- `contentContainerStyle` -> `tabBarContentContainerStyle`
462549
- `style` -> `tabBarStyle`
463550
464-
To keep the same behavior as before, you can specify these in `screenOptions`.
551+
The old options will still keep working with a deprecation warning. To avoid the deprecation warning, move these to `screenOptions`.
465552
466553
### The `lazy` prop is moved to `lazy` option for per-screen configuration for material top tabs
467554
@@ -471,7 +558,7 @@ Similar to bottom tabs, the `lazy` prop is now moved to `options` for material t
471558
472559
The `lazyPlaceholder` prop is now moved to `options` for material top tabs so you can configure a placeholder in each screen's options.
473560

474-
### The default value for `backBehavior` is now `firstRoute` for material top tabs tabs
561+
### The default value for `backBehavior` is now `firstRoute` for material top tabs
475562

476563
Similar to bottom tabs, material top tabs now uses `firstRoute` for the `backBehavior` prop as well.
477564

@@ -485,7 +572,9 @@ To install the 6.x version of `@react-navigation/material-bottom-tabs`, run:
485572
npm install @react-navigation/material-bottom-tabs
486573
```
487574

488-
It's also necessary to install the `react-native-safe-area-context` package when using `@react-navigation/material-bottom-tab`, if you didn't have it already:
575+
### Material Bottom Tabs now uses `react-native-safe-area-context` to apply safe area insets
576+
577+
It's now necessary to install the `react-native-safe-area-context` package when using `@react-navigation/material-bottom-tab`, if you didn't have it already.
489578

490579
### The default value for `backBehavior` is now `firstRoute` for material bottom tabs
491580

@@ -553,7 +642,7 @@ The following options have been moved and renamed:
553642
- `edgeWidth` -> `swipeEdgeWidth`
554643
- `minSwipeDistance` -> `swipeMinDistance`
555644

556-
To keep the same behavior as before, you can specify these in `screenOptions`.
645+
The old options will still keep working with a deprecation warning. To avoid the deprecation warning, move these to `screenOptions`.
557646

558647
### The `lazy` prop is moved to `lazy` option for per-screen configuration for drawer
559648

0 commit comments

Comments
 (0)