@react-navigation/stack 6.3.16 → 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +4 -5
  2. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  3. package/lib/commonjs/index.js +14 -15
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/navigators/createStackNavigator.js +6 -27
  6. package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
  7. package/lib/commonjs/utils/CardAnimationContext.js +3 -3
  8. package/lib/commonjs/utils/CardAnimationContext.js.map +1 -1
  9. package/lib/commonjs/utils/GestureHandlerRefContext.js +3 -3
  10. package/lib/commonjs/utils/GestureHandlerRefContext.js.map +1 -1
  11. package/lib/commonjs/utils/ModalPresentationContext.js +2 -3
  12. package/lib/commonjs/utils/ModalPresentationContext.js.map +1 -1
  13. package/lib/commonjs/utils/conditional.js +1 -1
  14. package/lib/commonjs/utils/conditional.js.map +1 -1
  15. package/lib/commonjs/utils/debounce.js +1 -2
  16. package/lib/commonjs/utils/debounce.js.map +1 -1
  17. package/lib/commonjs/utils/findLastIndex.js +1 -1
  18. package/lib/commonjs/utils/findLastIndex.js.map +1 -1
  19. package/lib/commonjs/utils/getDistanceForDirection.js +3 -4
  20. package/lib/commonjs/utils/getDistanceForDirection.js.map +1 -1
  21. package/lib/commonjs/utils/getInvertedMultiplier.js +1 -1
  22. package/lib/commonjs/utils/getInvertedMultiplier.js.map +1 -1
  23. package/lib/commonjs/utils/memoize.js +1 -1
  24. package/lib/commonjs/utils/memoize.js.map +1 -1
  25. package/lib/commonjs/utils/useCardAnimation.js +3 -4
  26. package/lib/commonjs/utils/useCardAnimation.js.map +1 -1
  27. package/lib/commonjs/utils/useGestureHandlerRef.js +3 -4
  28. package/lib/commonjs/utils/useGestureHandlerRef.js.map +1 -1
  29. package/lib/commonjs/utils/useKeyboardManager.js +1 -1
  30. package/lib/commonjs/utils/useKeyboardManager.js.map +1 -1
  31. package/lib/commonjs/views/GestureHandlerNative.js +2 -3
  32. package/lib/commonjs/views/GestureHandlerNative.js.map +1 -1
  33. package/lib/commonjs/views/Header/Header.js +9 -10
  34. package/lib/commonjs/views/Header/Header.js.map +1 -1
  35. package/lib/commonjs/views/Header/HeaderContainer.js +3 -4
  36. package/lib/commonjs/views/Header/HeaderContainer.js.map +1 -1
  37. package/lib/commonjs/views/Header/HeaderSegment.js +3 -4
  38. package/lib/commonjs/views/Header/HeaderSegment.js.map +1 -1
  39. package/lib/commonjs/views/ModalStatusBarManager.js +1 -1
  40. package/lib/commonjs/views/ModalStatusBarManager.js.map +1 -1
  41. package/lib/commonjs/views/Stack/Card.js +18 -18
  42. package/lib/commonjs/views/Stack/Card.js.map +1 -1
  43. package/lib/commonjs/views/Stack/CardContainer.js +10 -11
  44. package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
  45. package/lib/commonjs/views/Stack/CardSheet.js +3 -3
  46. package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
  47. package/lib/commonjs/views/Stack/CardStack.js +8 -8
  48. package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
  49. package/lib/commonjs/views/Stack/StackView.js +15 -9
  50. package/lib/commonjs/views/Stack/StackView.js.map +1 -1
  51. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +1 -1
  52. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  53. package/lib/module/index.js +7 -7
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/navigators/createStackNavigator.js +3 -23
  56. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  57. package/lib/module/utils/CardAnimationContext.js +1 -1
  58. package/lib/module/utils/CardAnimationContext.js.map +1 -1
  59. package/lib/module/utils/GestureHandlerRefContext.js +1 -1
  60. package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
  61. package/lib/module/utils/ModalPresentationContext.js +1 -2
  62. package/lib/module/utils/ModalPresentationContext.js.map +1 -1
  63. package/lib/module/utils/conditional.js +1 -1
  64. package/lib/module/utils/conditional.js.map +1 -1
  65. package/lib/module/utils/debounce.js +1 -2
  66. package/lib/module/utils/debounce.js.map +1 -1
  67. package/lib/module/utils/findLastIndex.js +1 -1
  68. package/lib/module/utils/findLastIndex.js.map +1 -1
  69. package/lib/module/utils/getDistanceForDirection.js +2 -2
  70. package/lib/module/utils/getDistanceForDirection.js.map +1 -1
  71. package/lib/module/utils/getInvertedMultiplier.js +1 -1
  72. package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
  73. package/lib/module/utils/memoize.js +1 -1
  74. package/lib/module/utils/memoize.js.map +1 -1
  75. package/lib/module/utils/useCardAnimation.js +2 -2
  76. package/lib/module/utils/useCardAnimation.js.map +1 -1
  77. package/lib/module/utils/useGestureHandlerRef.js +3 -3
  78. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  79. package/lib/module/utils/useKeyboardManager.js +1 -1
  80. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  81. package/lib/module/views/GestureHandlerNative.js +1 -1
  82. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  83. package/lib/module/views/Header/Header.js +4 -4
  84. package/lib/module/views/Header/Header.js.map +1 -1
  85. package/lib/module/views/Header/HeaderContainer.js +2 -2
  86. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  87. package/lib/module/views/Header/HeaderSegment.js +2 -2
  88. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  89. package/lib/module/views/ModalStatusBarManager.js +1 -1
  90. package/lib/module/views/ModalStatusBarManager.js.map +1 -1
  91. package/lib/module/views/Stack/Card.js +7 -7
  92. package/lib/module/views/Stack/Card.js.map +1 -1
  93. package/lib/module/views/Stack/CardContainer.js +5 -5
  94. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  95. package/lib/module/views/Stack/CardSheet.js +1 -1
  96. package/lib/module/views/Stack/CardSheet.js.map +1 -1
  97. package/lib/module/views/Stack/CardStack.js +4 -4
  98. package/lib/module/views/Stack/CardStack.js.map +1 -1
  99. package/lib/module/views/Stack/StackView.js +13 -6
  100. package/lib/module/views/Stack/StackView.js.map +1 -1
  101. package/lib/typescript/src/index.d.ts +7 -7
  102. package/lib/typescript/src/index.d.ts.map +1 -1
  103. package/lib/typescript/src/navigators/createStackNavigator.d.ts +8 -3
  104. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
  105. package/lib/typescript/src/types.d.ts +36 -36
  106. package/lib/typescript/src/types.d.ts.map +1 -1
  107. package/lib/typescript/src/utils/CardAnimationContext.d.ts +1 -2
  108. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
  109. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +1 -2
  110. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +1 -1
  111. package/lib/typescript/src/utils/ModalPresentationContext.d.ts +1 -2
  112. package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +1 -1
  113. package/lib/typescript/src/utils/conditional.d.ts +1 -1
  114. package/lib/typescript/src/utils/conditional.d.ts.map +1 -1
  115. package/lib/typescript/src/utils/debounce.d.ts +1 -1
  116. package/lib/typescript/src/utils/debounce.d.ts.map +1 -1
  117. package/lib/typescript/src/utils/findLastIndex.d.ts +1 -1
  118. package/lib/typescript/src/utils/findLastIndex.d.ts.map +1 -1
  119. package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
  120. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
  121. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
  122. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
  123. package/lib/typescript/src/utils/memoize.d.ts +1 -1
  124. package/lib/typescript/src/utils/memoize.d.ts.map +1 -1
  125. package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
  126. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
  127. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +1 -1
  128. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +1 -1
  129. package/lib/typescript/src/utils/useKeyboardManager.d.ts +1 -1
  130. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
  131. package/lib/typescript/src/views/Header/Header.d.ts +1 -2
  132. package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
  133. package/lib/typescript/src/views/Header/HeaderContainer.d.ts +2 -2
  134. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
  135. package/lib/typescript/src/views/Header/HeaderSegment.d.ts +2 -2
  136. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
  137. package/lib/typescript/src/views/ModalStatusBarManager.d.ts +2 -2
  138. package/lib/typescript/src/views/ModalStatusBarManager.d.ts.map +1 -1
  139. package/lib/typescript/src/views/Screens.d.ts +1 -1
  140. package/lib/typescript/src/views/Screens.d.ts.map +1 -1
  141. package/lib/typescript/src/views/Stack/Card.d.ts +4 -4
  142. package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
  143. package/lib/typescript/src/views/Stack/CardContainer.d.ts +4 -4
  144. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
  145. package/lib/typescript/src/views/Stack/CardSheet.d.ts +2 -3
  146. package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +1 -1
  147. package/lib/typescript/src/views/Stack/CardStack.d.ts +4 -4
  148. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  149. package/lib/typescript/src/views/Stack/StackView.d.ts +3 -3
  150. package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
  151. package/package.json +15 -16
  152. package/src/TransitionConfigs/CardStyleInterpolators.tsx +1 -1
  153. package/src/index.tsx +7 -7
  154. package/src/navigators/createStackNavigator.tsx +2 -41
  155. package/src/types.tsx +11 -11
  156. package/src/utils/CardAnimationContext.tsx +3 -3
  157. package/src/utils/GestureHandlerRefContext.tsx +1 -1
  158. package/src/utils/ModalPresentationContext.tsx +1 -3
  159. package/src/utils/conditional.tsx +4 -4
  160. package/src/utils/debounce.tsx +1 -2
  161. package/src/utils/findLastIndex.tsx +1 -4
  162. package/src/utils/getDistanceForDirection.tsx +2 -2
  163. package/src/utils/getInvertedMultiplier.tsx +1 -1
  164. package/src/utils/memoize.tsx +1 -1
  165. package/src/utils/useCardAnimation.tsx +2 -2
  166. package/src/utils/useGestureHandlerRef.tsx +3 -3
  167. package/src/utils/useKeyboardManager.tsx +1 -1
  168. package/src/views/GestureHandlerNative.tsx +1 -1
  169. package/src/views/Header/Header.tsx +4 -4
  170. package/src/views/Header/HeaderContainer.tsx +2 -2
  171. package/src/views/Header/HeaderSegment.tsx +4 -4
  172. package/src/views/ModalStatusBarManager.tsx +1 -6
  173. package/src/views/Screens.tsx +1 -1
  174. package/src/views/Stack/Card.tsx +11 -11
  175. package/src/views/Stack/CardContainer.tsx +5 -5
  176. package/src/views/Stack/CardSheet.tsx +33 -34
  177. package/src/views/Stack/CardStack.tsx +10 -5
  178. package/src/views/Stack/StackView.tsx +18 -5
@@ -29,7 +29,7 @@ export const MaybeScreen = ({
29
29
  ...rest
30
30
  }: ViewProps & {
31
31
  enabled: boolean;
32
- active: 0 | 1 | Animated.AnimatedInterpolation;
32
+ active: 0 | 1 | Animated.AnimatedInterpolation<0 | 1>;
33
33
  children: React.ReactNode;
34
34
  freezeOnBlur?: boolean;
35
35
  }) => {
@@ -20,23 +20,23 @@ import type {
20
20
  StackCardStyleInterpolator,
21
21
  TransitionSpec,
22
22
  } from '../../types';
23
- import CardAnimationContext from '../../utils/CardAnimationContext';
24
- import getDistanceForDirection from '../../utils/getDistanceForDirection';
25
- import getInvertedMultiplier from '../../utils/getInvertedMultiplier';
26
- import memoize from '../../utils/memoize';
23
+ import { CardAnimationContext } from '../../utils/CardAnimationContext';
24
+ import { getDistanceForDirection } from '../../utils/getDistanceForDirection';
25
+ import { getInvertedMultiplier } from '../../utils/getInvertedMultiplier';
26
+ import { memoize } from '../../utils/memoize';
27
27
  import {
28
28
  GestureState,
29
29
  PanGestureHandler,
30
30
  PanGestureHandlerGestureEvent,
31
31
  } from '../GestureHandler';
32
- import ModalStatusBarManager from '../ModalStatusBarManager';
33
- import CardSheet, { CardSheetRef } from './CardSheet';
32
+ import { ModalStatusBarManager } from '../ModalStatusBarManager';
33
+ import { CardSheet, CardSheetRef } from './CardSheet';
34
34
 
35
35
  type Props = ViewProps & {
36
36
  interpolationIndex: number;
37
37
  closing: boolean;
38
- next?: Animated.AnimatedInterpolation;
39
- current: Animated.AnimatedInterpolation;
38
+ next?: Animated.AnimatedInterpolation<number>;
39
+ current: Animated.AnimatedInterpolation<number>;
40
40
  gesture: Animated.Value;
41
41
  layout: Layout;
42
42
  insets: EdgeInsets;
@@ -89,7 +89,7 @@ const hasOpacityStyle = (style: any) => {
89
89
  return false;
90
90
  };
91
91
 
92
- export default class Card extends React.Component<Props> {
92
+ export class Card extends React.Component<Props> {
93
93
  static defaultProps = {
94
94
  shadowEnabled: false,
95
95
  gestureEnabled: true,
@@ -351,8 +351,8 @@ export default class Card extends React.Component<Props> {
351
351
  private getCardAnimation = memoize(
352
352
  (
353
353
  interpolationIndex: number,
354
- current: Animated.AnimatedInterpolation,
355
- next: Animated.AnimatedInterpolation | undefined,
354
+ current: Animated.AnimatedInterpolation<number>,
355
+ next: Animated.AnimatedInterpolation<number> | undefined,
356
356
  layout: Layout,
357
357
  insetTop: number,
358
358
  insetRight: number,
@@ -9,10 +9,10 @@ import * as React from 'react';
9
9
  import { Animated, StyleSheet, View } from 'react-native';
10
10
 
11
11
  import type { Layout, Scene } from '../../types';
12
- import ModalPresentationContext from '../../utils/ModalPresentationContext';
13
- import useKeyboardManager from '../../utils/useKeyboardManager';
12
+ import { ModalPresentationContext } from '../../utils/ModalPresentationContext';
13
+ import { useKeyboardManager } from '../../utils/useKeyboardManager';
14
14
  import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
15
- import Card from './Card';
15
+ import { Card } from './Card';
16
16
 
17
17
  type Props = {
18
18
  interpolationIndex: number;
@@ -56,7 +56,7 @@ type Props = {
56
56
 
57
57
  const EPSILON = 0.1;
58
58
 
59
- function CardContainer({
59
+ function CardContainerInner({
60
60
  interpolationIndex,
61
61
  index,
62
62
  active,
@@ -307,7 +307,7 @@ function CardContainer({
307
307
  );
308
308
  }
309
309
 
310
- export default React.memo(CardContainer);
310
+ export const CardContainer = React.memo(CardContainerInner);
311
311
 
312
312
  const styles = StyleSheet.create({
313
313
  container: {
@@ -15,40 +15,39 @@ export type CardSheetRef = {
15
15
  // if the container fills the body by comparing the size
16
16
  // This lets the document.body handle scrolling of the content
17
17
  // It's necessary for mobile browsers to be able to hide address bar on scroll
18
- export default React.forwardRef<CardSheetRef, Props>(function CardSheet(
19
- { enabled, layout, style, ...rest },
20
- ref
21
- ) {
22
- const [fill, setFill] = React.useState(false);
23
- // To avoid triggering a rerender in Card during animation we had to move
24
- // the state to CardSheet. The `setPointerEvents` is then hoisted back to the Card.
25
- const [pointerEvents, setPointerEvents] =
26
- React.useState<ViewProps['pointerEvents']>('auto');
27
-
28
- React.useImperativeHandle(ref, () => {
29
- return { setPointerEvents };
30
- });
31
-
32
- React.useEffect(() => {
33
- if (typeof document === 'undefined' || !document.body) {
34
- // Only run when DOM is available
35
- return;
36
- }
37
-
38
- const width = document.body.clientWidth;
39
- const height = document.body.clientHeight;
40
-
41
- setFill(width === layout.width && height === layout.height);
42
- }, [layout.height, layout.width]);
43
-
44
- return (
45
- <View
46
- {...rest}
47
- pointerEvents={pointerEvents}
48
- style={[enabled && fill ? styles.page : styles.card, style]}
49
- />
50
- );
51
- });
18
+ export const CardSheet = React.forwardRef<CardSheetRef, Props>(
19
+ function CardSheet({ enabled, layout, style, ...rest }, ref) {
20
+ const [fill, setFill] = React.useState(false);
21
+ // To avoid triggering a rerender in Card during animation we had to move
22
+ // the state to CardSheet. The `setPointerEvents` is then hoisted back to the Card.
23
+ const [pointerEvents, setPointerEvents] =
24
+ React.useState<ViewProps['pointerEvents']>('auto');
25
+
26
+ React.useImperativeHandle(ref, () => {
27
+ return { setPointerEvents };
28
+ });
29
+
30
+ React.useEffect(() => {
31
+ if (typeof document === 'undefined' || !document.body) {
32
+ // Only run when DOM is available
33
+ return;
34
+ }
35
+
36
+ const width = document.body.clientWidth;
37
+ const height = document.body.clientHeight;
38
+
39
+ setFill(width === layout.width && height === layout.height);
40
+ }, [layout.height, layout.width]);
41
+
42
+ return (
43
+ <View
44
+ {...rest}
45
+ pointerEvents={pointerEvents}
46
+ style={[enabled && fill ? styles.page : styles.card, style]}
47
+ />
48
+ );
49
+ }
50
+ );
52
51
 
53
52
  const styles = StyleSheet.create({
54
53
  page: {
@@ -35,12 +35,12 @@ import type {
35
35
  StackHeaderMode,
36
36
  StackNavigationOptions,
37
37
  } from '../../types';
38
- import findLastIndex from '../../utils/findLastIndex';
39
- import getDistanceForDirection from '../../utils/getDistanceForDirection';
38
+ import { findLastIndex } from '../../utils/findLastIndex';
39
+ import { getDistanceForDirection } from '../../utils/getDistanceForDirection';
40
40
  import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
41
41
  import { MaybeScreen, MaybeScreenContainer } from '../Screens';
42
42
  import { getIsModalPresentation } from './Card';
43
- import CardContainer from './CardContainer';
43
+ import { CardContainer } from './CardContainer';
44
44
 
45
45
  type GestureValues = {
46
46
  [key: string]: Animated.Value;
@@ -51,6 +51,7 @@ type Props = {
51
51
  state: StackNavigationState<ParamListBase>;
52
52
  descriptors: StackDescriptorMap;
53
53
  routes: Route<string>[];
54
+ // eslint-disable-next-line react/no-unused-prop-types
54
55
  openingRouteKeys: string[];
55
56
  closingRouteKeys: string[];
56
57
  onOpenRoute: (props: { route: Route<string> }) => void;
@@ -201,7 +202,7 @@ const getProgressFromGesture = (
201
202
  });
202
203
  };
203
204
 
204
- export default class CardStack extends React.Component<Props, State> {
205
+ export class CardStack extends React.Component<Props, State> {
205
206
  static getDerivedStateFromProps(
206
207
  props: Props,
207
208
  state: State
@@ -583,7 +584,11 @@ export default class CardStack extends React.Component<Props, State> {
583
584
  // For those that should be active, but are not the top screen, the value is 1
584
585
  // For those on top of the stack and with interaction enabled, the value is 2
585
586
  // For the old implementation, it stays the same it was
586
- let isScreenActive: Animated.AnimatedInterpolation | 2 | 1 | 0 = 1;
587
+ let isScreenActive:
588
+ | Animated.AnimatedInterpolation<0 | 1 | 2>
589
+ | 0
590
+ | 1
591
+ | 2 = 1;
587
592
 
588
593
  if (index < self.length - activeScreensLimit - 1) {
589
594
  // screen should be inactive because it is too deep in the stack
@@ -3,6 +3,7 @@ import {
3
3
  SafeAreaProviderCompat,
4
4
  } from '@react-navigation/elements';
5
5
  import {
6
+ CommonActions,
6
7
  ParamListBase,
7
8
  Route,
8
9
  StackActions,
@@ -20,12 +21,13 @@ import type {
20
21
  StackNavigationConfig,
21
22
  StackNavigationHelpers,
22
23
  } from '../../types';
23
- import ModalPresentationContext from '../../utils/ModalPresentationContext';
24
+ import { ModalPresentationContext } from '../../utils/ModalPresentationContext';
24
25
  import { GestureHandlerRootView } from '../GestureHandler';
25
- import HeaderContainer, {
26
+ import {
27
+ HeaderContainer,
26
28
  Props as HeaderContainerProps,
27
29
  } from '../Header/HeaderContainer';
28
- import CardStack from './CardStack';
30
+ import { CardStack } from './CardStack';
29
31
 
30
32
  type Props = StackNavigationConfig & {
31
33
  state: StackNavigationState<ParamListBase>;
@@ -60,7 +62,7 @@ const GestureHandlerWrapper = GestureHandlerRootView ?? View;
60
62
  const isArrayEqual = (a: any[], b: any[]) =>
61
63
  a.length === b.length && a.every((it, index) => it === b[index]);
62
64
 
63
- export default class StackView extends React.Component<Props, State> {
65
+ export class StackView extends React.Component<Props, State> {
64
66
  static getDerivedStateFromProps(
65
67
  props: Readonly<Props>,
66
68
  state: Readonly<State>
@@ -328,7 +330,18 @@ export default class StackView extends React.Component<Props, State> {
328
330
  ) {
329
331
  // If route isn't present in current state, but was closing, assume that a close animation was cancelled
330
332
  // So we need to add this route back to the state
331
- navigation.navigate(route);
333
+ navigation.dispatch((state) => {
334
+ const routes = [
335
+ ...state.routes.filter((r) => r.key !== route.key),
336
+ route,
337
+ ];
338
+
339
+ return CommonActions.reset({
340
+ ...state,
341
+ routes,
342
+ index: routes.length - 1,
343
+ });
344
+ });
332
345
  } else {
333
346
  this.setState((state) => ({
334
347
  routes: state.replacingRouteKeys.length