@react-navigation/core 7.23.0 → 7.25.0
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.
- package/lib/module/BaseNavigationContainer.js +48 -21
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/NavigationBuilderContext.js +7 -11
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +41 -10
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +2 -2
- package/lib/module/NavigationProvider.js.map +1 -1
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +0 -1
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js +25 -18
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/StaticNavigation.js +53 -18
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/types.js +7 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDescriptors.js +5 -5
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +2 -2
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/module/useKeyedChildListeners.js +3 -1
- package/lib/module/useKeyedChildListeners.js.map +1 -1
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +6 -4
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +15 -27
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +17 -7
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationState.js +1 -1
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +2 -2
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +2 -2
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +2 -2
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js +2 -2
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +4 -8
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +2 -2
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +11 -7
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
- package/lib/typescript/src/NavigationStateContext.d.ts +0 -1
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +49 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +2 -5
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +5 -0
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +2 -0
- package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/package.json +14 -15
- package/src/BaseNavigationContainer.tsx +69 -31
- package/src/NavigationBuilderContext.tsx +27 -17
- package/src/NavigationIndependentTree.tsx +41 -13
- package/src/NavigationProvider.tsx +11 -8
- package/src/NavigationStateContext.tsx +0 -4
- package/src/PreventRemoveProvider.tsx +0 -1
- package/src/SceneView.tsx +22 -27
- package/src/StaticNavigation.tsx +71 -17
- package/src/types.tsx +76 -8
- package/src/useDescriptors.tsx +5 -4
- package/src/useFocusedListenersChildrenAdapter.tsx +2 -2
- package/src/useKeyedChildListeners.tsx +1 -0
- package/src/useNavigation.tsx +2 -5
- package/src/useNavigationBuilder.tsx +5 -6
- package/src/useNavigationCache.tsx +14 -31
- package/src/useNavigationHelpers.tsx +18 -6
- package/src/useNavigationState.tsx +1 -1
- package/src/useOnAction.tsx +2 -2
- package/src/useOnGetState.tsx +2 -2
- package/src/useOnPreventRemove.tsx +2 -2
- package/src/useOnRouteFocus.tsx +2 -4
- package/src/useOptionsGetters.tsx +9 -6
- package/src/useScheduleUpdate.tsx +2 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationHelpers.d.ts","sourceRoot":"","sources":["../../../src/useNavigationHelpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"useNavigationHelpers.d.ts","sourceRoot":"","sources":["../../../src/useNavigationHelpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,KAAK,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAS,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAmB,CAAC;AAMhE,KAAK,OAAO,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,SAAS,gBAAgB,IAAI;IAC7E,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC;IAChD,iBAAiB,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,EAChD,MAAM,SAAS,gBAAgB,EAC/B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpC,EACA,EAAE,EAAE,WAAW,EACf,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,OAAO,EACP,MAAM,GACP,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiHxB"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { NavigationState, ParamListBase } from '@react-navigation/routers';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
type NavigationStateListener = {
|
|
4
|
+
getState: () => NavigationState<ParamListBase>;
|
|
5
|
+
subscribe: (callback: () => void) => () => void;
|
|
6
|
+
};
|
|
3
7
|
type Selector<ParamList extends ParamListBase, T> = (state: NavigationState<ParamList>) => T;
|
|
4
8
|
/**
|
|
5
9
|
* Hook to get a value from the current navigation state using a selector.
|
|
@@ -12,5 +16,6 @@ export declare function NavigationStateListenerProvider({ state, getState, child
|
|
|
12
16
|
getState: () => NavigationState<ParamListBase>;
|
|
13
17
|
children: React.ReactNode;
|
|
14
18
|
}): React.JSX.Element;
|
|
19
|
+
export declare const NavigationStateListenerContext: React.Context<NavigationStateListener | undefined>;
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=useNavigationState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationState.d.ts","sourceRoot":"","sources":["../../../src/useNavigationState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useNavigationState.d.ts","sourceRoot":"","sources":["../../../src/useNavigationState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,eAAe,CAAC,aAAa,CAAC,CAAC;IAC/C,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACjD,CAAC;AAEF,KAAK,QAAQ,CAAC,SAAS,SAAS,aAAa,EAAE,CAAC,IAAI,CAClD,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,KAC9B,CAAC,CAAC;AAEP;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,SAAS,aAAa,EAAE,CAAC,EACnE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,GAC/B,CAAC,CA+CH;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACtC,QAAQ,EAAE,MAAM,eAAe,CAAC,aAAa,CAAC,CAAC;IAC/C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBA6BA;AAED,eAAO,MAAM,8BAA8B,oDAE/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnRouteFocus.d.ts","sourceRoot":"","sources":["../../../src/useOnRouteFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,2BAA2B,CAAC;AAKnC,KAAK,OAAO,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,SAAS,gBAAgB,IAAI;IAC7E,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,SAAS,eAAe,EAC7B,MAAM,SAAS,gBAAgB,EAC/B,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"useOnRouteFocus.d.ts","sourceRoot":"","sources":["../../../src/useOnRouteFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,2BAA2B,CAAC;AAKnC,KAAK,OAAO,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,SAAS,gBAAgB,IAAI;IAC7E,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,SAAS,eAAe,EAC7B,MAAM,SAAS,gBAAgB,EAC/B,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,SAInE,MAAM,UAcf"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ParamListBase } from '@react-navigation/routers';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import type { NavigationProp } from './types.js';
|
|
4
|
+
export declare const OptionsGetterContext: React.Context<((key: string, getter: () => object | undefined | null) => void) | undefined>;
|
|
3
5
|
type Options = {
|
|
4
6
|
key?: string;
|
|
5
7
|
navigation?: NavigationProp<ParamListBase>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOptionsGetters.d.ts","sourceRoot":"","sources":["../../../src/useOptionsGetters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"useOptionsGetters.d.ts","sourceRoot":"","sources":["../../../src/useOptionsGetters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAS,CAAC;AAE9C,eAAO,MAAM,oBAAoB,uBACxB,MAAM,UAAU,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,KAAK,IAAI,cACrD,CAAC;AAEb,KAAK,OAAO,GAAG;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,OAAO;4BAkE7D,MAAM,UAAU,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI;;EAiBxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScheduleUpdate.d.ts","sourceRoot":"","sources":["../../../src/useScheduleUpdate.tsx"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"useScheduleUpdate.d.ts","sourceRoot":"","sources":["../../../src/useScheduleUpdate.tsx"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,QAQrD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/core",
|
|
3
3
|
"description": "Core utilities for building navigators",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.25.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"react-native",
|
|
@@ -40,24 +40,23 @@
|
|
|
40
40
|
"clean": "del lib"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@react-navigation/routers": "^7.6.
|
|
43
|
+
"@react-navigation/routers": "^7.6.6",
|
|
44
44
|
"escape-string-regexp": "^4.0.0",
|
|
45
45
|
"fast-deep-equal": "^3.1.3",
|
|
46
|
-
"react-is": "^19.1
|
|
47
|
-
"use-latest-callback": "^0.2.4"
|
|
48
|
-
"use-sync-external-store": "^1.5.0"
|
|
46
|
+
"react-is": "^19.3.1",
|
|
47
|
+
"use-latest-callback": "^0.2.4"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@jest/globals": "^30.
|
|
50
|
+
"@jest/globals": "^30.5.2",
|
|
52
51
|
"@testing-library/react-native": "^13.2.1",
|
|
53
|
-
"@types/react": "~19.
|
|
54
|
-
"@types/react-is": "^19.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"react": "
|
|
59
|
-
"react-native-builder-bob": "^0.
|
|
60
|
-
"react-test-renderer": "19.
|
|
52
|
+
"@types/react": "~19.3.0",
|
|
53
|
+
"@types/react-is": "^19.3.0",
|
|
54
|
+
"del-cli": "^8.0.1",
|
|
55
|
+
"immer": "^11.2.9",
|
|
56
|
+
"react": "19.3.0",
|
|
57
|
+
"react-native": "0.88.1",
|
|
58
|
+
"react-native-builder-bob": "^0.44.1",
|
|
59
|
+
"react-test-renderer": "19.3.0",
|
|
61
60
|
"typescript": "~6.0.3"
|
|
62
61
|
},
|
|
63
62
|
"peerDependencies": {
|
|
@@ -81,5 +80,5 @@
|
|
|
81
80
|
]
|
|
82
81
|
]
|
|
83
82
|
},
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "77fad70cd6d9ed492d7ce30177efa923e95294cb"
|
|
85
84
|
}
|
|
@@ -17,7 +17,10 @@ import { NOT_INITIALIZED_ERROR } from './createNavigationContainerRef';
|
|
|
17
17
|
import { DeprecatedNavigationInChildContext } from './DeprecatedNavigationInChildContext';
|
|
18
18
|
import { EnsureSingleNavigator } from './EnsureSingleNavigator';
|
|
19
19
|
import { findFocusedRoute } from './findFocusedRoute';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
NavigationBuilderContext,
|
|
22
|
+
type WithStackTrace,
|
|
23
|
+
} from './NavigationBuilderContext';
|
|
21
24
|
import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
22
25
|
import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
|
|
23
26
|
import { NavigationStateContext } from './NavigationStateContext';
|
|
@@ -33,7 +36,7 @@ import { useEventEmitter } from './useEventEmitter';
|
|
|
33
36
|
import { useKeyedChildListeners } from './useKeyedChildListeners';
|
|
34
37
|
import { useLazyValue } from './useLazyValue';
|
|
35
38
|
import { useNavigationIndependentTree } from './useNavigationIndependentTree';
|
|
36
|
-
import { useOptionsGetters } from './useOptionsGetters';
|
|
39
|
+
import { OptionsGetterContext, useOptionsGetters } from './useOptionsGetters';
|
|
37
40
|
import { useSyncState } from './useSyncState';
|
|
38
41
|
|
|
39
42
|
type State = NavigationState | PartialState<NavigationState> | undefined;
|
|
@@ -126,6 +129,41 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
126
129
|
|
|
127
130
|
const { keyedListeners, addKeyedListener } = useKeyedChildListeners();
|
|
128
131
|
|
|
132
|
+
const stackRef = React.useRef<string | undefined>(undefined);
|
|
133
|
+
|
|
134
|
+
const withStackTrace = React.useCallback<WithStackTrace>(
|
|
135
|
+
(entry, callback) => {
|
|
136
|
+
if (process.env.NODE_ENV === 'production' || stackRef.current != null) {
|
|
137
|
+
callback();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const error = new Error();
|
|
142
|
+
|
|
143
|
+
if (Error.captureStackTrace) {
|
|
144
|
+
// Available on V8 and Hermes, omits the frames of `entry` and what it called
|
|
145
|
+
Error.captureStackTrace(error, entry);
|
|
146
|
+
|
|
147
|
+
stackRef.current = error.stack;
|
|
148
|
+
} else {
|
|
149
|
+
// Other engines always include them, so we drop the frames up to `entry` ourselves
|
|
150
|
+
const frames = error.stack?.split('\n') ?? [];
|
|
151
|
+
const index = frames.findIndex((frame) =>
|
|
152
|
+
frame.includes(`${entry.name}@`)
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
stackRef.current = frames.slice(index + 1).join('\n');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
callback();
|
|
160
|
+
} finally {
|
|
161
|
+
stackRef.current = undefined;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
[]
|
|
165
|
+
);
|
|
166
|
+
|
|
129
167
|
const dispatch = useLatestCallback(
|
|
130
168
|
(
|
|
131
169
|
action:
|
|
@@ -135,7 +173,9 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
135
173
|
if (listeners.focus[0] == null) {
|
|
136
174
|
console.error(NOT_INITIALIZED_ERROR);
|
|
137
175
|
} else {
|
|
138
|
-
|
|
176
|
+
withStackTrace(dispatch, () => {
|
|
177
|
+
listeners.focus[0]((navigation) => navigation.dispatch(action));
|
|
178
|
+
});
|
|
139
179
|
}
|
|
140
180
|
}
|
|
141
181
|
);
|
|
@@ -198,9 +238,14 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
198
238
|
const navigation: NavigationContainerRef<ParamListBase> = React.useMemo(
|
|
199
239
|
() => ({
|
|
200
240
|
...Object.keys(CommonActions).reduce<any>((acc, name) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
241
|
+
const helper = (...args: any[]) =>
|
|
242
|
+
withStackTrace(helper, () =>
|
|
243
|
+
// @ts-expect-error: this is ok
|
|
244
|
+
dispatch(CommonActions[name](...args))
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
acc[name] = helper;
|
|
248
|
+
|
|
204
249
|
return acc;
|
|
205
250
|
}, {}),
|
|
206
251
|
...emitter.create('root'),
|
|
@@ -228,6 +273,7 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
228
273
|
getState,
|
|
229
274
|
isReady,
|
|
230
275
|
resetRoot,
|
|
276
|
+
withStackTrace,
|
|
231
277
|
]
|
|
232
278
|
);
|
|
233
279
|
|
|
@@ -266,8 +312,6 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
266
312
|
});
|
|
267
313
|
});
|
|
268
314
|
|
|
269
|
-
const stackRef = React.useRef<string | undefined>(undefined);
|
|
270
|
-
|
|
271
315
|
const lastEmittedStateRef = React.useRef<State | undefined>(undefined);
|
|
272
316
|
|
|
273
317
|
const getIsStateEmitted = useLatestCallback(
|
|
@@ -285,7 +329,7 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
285
329
|
getIsStateEmitted,
|
|
286
330
|
scheduleUpdate,
|
|
287
331
|
flushUpdates,
|
|
288
|
-
|
|
332
|
+
withStackTrace,
|
|
289
333
|
}),
|
|
290
334
|
[
|
|
291
335
|
addListener,
|
|
@@ -296,6 +340,7 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
296
340
|
getIsStateEmitted,
|
|
297
341
|
scheduleUpdate,
|
|
298
342
|
flushUpdates,
|
|
343
|
+
withStackTrace,
|
|
299
344
|
]
|
|
300
345
|
);
|
|
301
346
|
|
|
@@ -311,17 +356,8 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
311
356
|
getKey,
|
|
312
357
|
setKey,
|
|
313
358
|
getIsInitial,
|
|
314
|
-
addOptionsGetter,
|
|
315
359
|
}),
|
|
316
|
-
[
|
|
317
|
-
state,
|
|
318
|
-
getState,
|
|
319
|
-
setState,
|
|
320
|
-
getKey,
|
|
321
|
-
setKey,
|
|
322
|
-
getIsInitial,
|
|
323
|
-
addOptionsGetter,
|
|
324
|
-
]
|
|
360
|
+
[state, getState, setState, getKey, setKey, getIsInitial]
|
|
325
361
|
);
|
|
326
362
|
|
|
327
363
|
const onReadyRef = React.useRef(onReady);
|
|
@@ -475,19 +511,21 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
475
511
|
<NavigationContainerRefContext.Provider value={navigation}>
|
|
476
512
|
<NavigationBuilderContext.Provider value={builderContext}>
|
|
477
513
|
<NavigationStateContext.Provider value={context}>
|
|
478
|
-
<
|
|
479
|
-
<
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
<DeprecatedNavigationInChildContext.Provider
|
|
483
|
-
value={navigationInChildEnabled}
|
|
514
|
+
<OptionsGetterContext.Provider value={addOptionsGetter}>
|
|
515
|
+
<ConsumedParamsContext.Provider value={consumedParams}>
|
|
516
|
+
<UnhandledActionContext.Provider
|
|
517
|
+
value={onUnhandledAction ?? defaultOnUnhandledAction}
|
|
484
518
|
>
|
|
485
|
-
<
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
519
|
+
<DeprecatedNavigationInChildContext.Provider
|
|
520
|
+
value={navigationInChildEnabled}
|
|
521
|
+
>
|
|
522
|
+
<EnsureSingleNavigator>
|
|
523
|
+
<ThemeProvider value={theme}>{children}</ThemeProvider>
|
|
524
|
+
</EnsureSingleNavigator>
|
|
525
|
+
</DeprecatedNavigationInChildContext.Provider>
|
|
526
|
+
</UnhandledActionContext.Provider>
|
|
527
|
+
</ConsumedParamsContext.Provider>
|
|
528
|
+
</OptionsGetterContext.Provider>
|
|
491
529
|
</NavigationStateContext.Provider>
|
|
492
530
|
</NavigationBuilderContext.Provider>
|
|
493
531
|
</NavigationContainerRefContext.Provider>
|
|
@@ -47,15 +47,17 @@ export type FocusedNavigationListener = <T>(
|
|
|
47
47
|
|
|
48
48
|
export type GetStateListener = () => NavigationState;
|
|
49
49
|
|
|
50
|
+
export type WithStackTrace = (
|
|
51
|
+
entry: (...args: never[]) => void,
|
|
52
|
+
callback: () => void
|
|
53
|
+
) => void;
|
|
54
|
+
|
|
50
55
|
export type ChildBeforeRemoveListener = (
|
|
51
56
|
action: NavigationAction,
|
|
52
57
|
nextState: NavigationState | PartialState<NavigationState> | undefined
|
|
53
58
|
) => boolean;
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
* Context which holds the required helpers needed to build nested navigators.
|
|
57
|
-
*/
|
|
58
|
-
export const NavigationBuilderContext = React.createContext<{
|
|
60
|
+
type NavigationBuilderContextValue = {
|
|
59
61
|
onAction?: (
|
|
60
62
|
action: NavigationAction,
|
|
61
63
|
visitedNavigators?: Set<string>
|
|
@@ -71,16 +73,24 @@ export const NavigationBuilderContext = React.createContext<{
|
|
|
71
73
|
getIsStateEmitted: () => boolean;
|
|
72
74
|
scheduleUpdate: (callback: () => void) => void;
|
|
73
75
|
flushUpdates: () => void;
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
withStackTrace: WithStackTrace;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Context which holds the required helpers needed to build nested navigators.
|
|
81
|
+
*/
|
|
82
|
+
export const NavigationBuilderContext = React.createContext<
|
|
83
|
+
NavigationBuilderContextValue | undefined
|
|
84
|
+
>(undefined);
|
|
85
|
+
|
|
86
|
+
export function useNavigationBuilderContext() {
|
|
87
|
+
const value = React.useContext(NavigationBuilderContext);
|
|
88
|
+
|
|
89
|
+
if (value == null) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"Couldn't find a navigation builder context. Is your component inside NavigationContainer?"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
import { NavigationBuilderContext } from './NavigationBuilderContext';
|
|
4
|
+
import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
3
5
|
import { NavigationContext } from './NavigationContext';
|
|
4
6
|
import { NavigationFocusedRouteStateContext } from './NavigationFocusedRouteStateContext';
|
|
7
|
+
import { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
5
8
|
import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
|
|
6
|
-
|
|
7
|
-
import {
|
|
9
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
10
|
+
import { NavigationMetaContext } from './NavigationMetaContext';
|
|
11
|
+
import {
|
|
12
|
+
NamedRouteContextListContext,
|
|
13
|
+
NavigationRouteContext,
|
|
14
|
+
} from './NavigationProvider';
|
|
15
|
+
import { PreventRemoveContext } from './PreventRemoveContext';
|
|
16
|
+
import { FocusedRouteKeyContext, IsFocusedContext } from './useIsFocused';
|
|
17
|
+
import { NavigationStateListenerContext } from './useNavigationState';
|
|
8
18
|
|
|
9
19
|
/**
|
|
10
20
|
* Component to make the child navigation container independent of parent containers.
|
|
@@ -16,16 +26,34 @@ export function NavigationIndependentTree({
|
|
|
16
26
|
}) {
|
|
17
27
|
return (
|
|
18
28
|
// We need to clear any existing contexts for nested independent container to work correctly
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
<NavigationIndependentTreeContext.Provider value>
|
|
30
|
+
<NavigationContainerRefContext.Provider value={undefined}>
|
|
31
|
+
<NavigationBuilderContext.Provider value={undefined}>
|
|
32
|
+
<NavigationMetaContext.Provider value={undefined}>
|
|
33
|
+
<NavigationHelpersContext.Provider value={undefined}>
|
|
34
|
+
<NavigationStateListenerContext.Provider value={undefined}>
|
|
35
|
+
<FocusedRouteKeyContext.Provider value={undefined}>
|
|
36
|
+
<PreventRemoveContext.Provider value={undefined}>
|
|
37
|
+
<NamedRouteContextListContext.Provider value={undefined}>
|
|
38
|
+
<NavigationRouteContext.Provider value={undefined}>
|
|
39
|
+
<NavigationContext.Provider value={undefined}>
|
|
40
|
+
<IsFocusedContext.Provider value={undefined}>
|
|
41
|
+
<NavigationFocusedRouteStateContext.Provider
|
|
42
|
+
value={undefined}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</NavigationFocusedRouteStateContext.Provider>
|
|
46
|
+
</IsFocusedContext.Provider>
|
|
47
|
+
</NavigationContext.Provider>
|
|
48
|
+
</NavigationRouteContext.Provider>
|
|
49
|
+
</NamedRouteContextListContext.Provider>
|
|
50
|
+
</PreventRemoveContext.Provider>
|
|
51
|
+
</FocusedRouteKeyContext.Provider>
|
|
52
|
+
</NavigationStateListenerContext.Provider>
|
|
53
|
+
</NavigationHelpersContext.Provider>
|
|
54
|
+
</NavigationMetaContext.Provider>
|
|
55
|
+
</NavigationBuilderContext.Provider>
|
|
56
|
+
</NavigationContainerRefContext.Provider>
|
|
57
|
+
</NavigationIndependentTreeContext.Provider>
|
|
30
58
|
);
|
|
31
59
|
}
|
|
@@ -37,13 +37,16 @@ export function NavigationProvider({ route, navigation, children }: Props) {
|
|
|
37
37
|
? focusedRouteKey === route.key
|
|
38
38
|
: false;
|
|
39
39
|
|
|
40
|
-
return (
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
return React.useMemo(
|
|
41
|
+
() => (
|
|
42
|
+
<NavigationRouteContext.Provider value={route}>
|
|
43
|
+
<NavigationContext.Provider value={navigation}>
|
|
44
|
+
<IsFocusedContext.Provider value={isFocused}>
|
|
45
|
+
{children}
|
|
46
|
+
</IsFocusedContext.Provider>
|
|
47
|
+
</NavigationContext.Provider>
|
|
48
|
+
</NavigationRouteContext.Provider>
|
|
49
|
+
),
|
|
50
|
+
[children, isFocused, navigation, route]
|
|
48
51
|
);
|
|
49
52
|
}
|
|
@@ -14,10 +14,6 @@ export const NavigationStateContext = React.createContext<{
|
|
|
14
14
|
state: NavigationState | PartialState<NavigationState> | undefined
|
|
15
15
|
) => void;
|
|
16
16
|
getIsInitial: () => boolean;
|
|
17
|
-
addOptionsGetter?: (
|
|
18
|
-
key: string,
|
|
19
|
-
getter: () => object | undefined | null
|
|
20
|
-
) => void;
|
|
21
17
|
}>({
|
|
22
18
|
isDefault: true,
|
|
23
19
|
|
|
@@ -65,7 +65,6 @@ export function PreventRemoveProvider({ children }: Props) {
|
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
const notifyPreventRemove = useLatestCallback(() => {
|
|
68
|
-
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
69
68
|
setPreventedRoutesMap((prevPrevented) => {
|
|
70
69
|
const nextPrevented = registry.current;
|
|
71
70
|
|
package/src/SceneView.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { NavigationStateContext } from './NavigationStateContext';
|
|
16
16
|
import { StaticContainer } from './StaticContainer';
|
|
17
17
|
import type { NavigationProp, RouteConfigComponent } from './types';
|
|
18
|
-
import { useOptionsGetters } from './useOptionsGetters';
|
|
18
|
+
import { OptionsGetterContext, useOptionsGetters } from './useOptionsGetters';
|
|
19
19
|
|
|
20
20
|
type Props<State extends NavigationState, ScreenOptions extends {}> = {
|
|
21
21
|
screen: RouteConfigComponent<ParamListBase, string> & { name: string };
|
|
@@ -105,7 +105,7 @@ export function SceneView<
|
|
|
105
105
|
// Clear options set by this screen when it is unmounted
|
|
106
106
|
React.useEffect(() => {
|
|
107
107
|
return clearOptions;
|
|
108
|
-
// eslint-disable-next-line react
|
|
108
|
+
// eslint-disable-next-line @eslint-react/exhaustive-deps
|
|
109
109
|
}, []);
|
|
110
110
|
|
|
111
111
|
const getIsInitial = React.useCallback(() => isInitialRef.current, []);
|
|
@@ -163,40 +163,35 @@ export function SceneView<
|
|
|
163
163
|
getKey,
|
|
164
164
|
setKey,
|
|
165
165
|
getIsInitial,
|
|
166
|
-
addOptionsGetter,
|
|
167
166
|
}),
|
|
168
|
-
[
|
|
169
|
-
routeState,
|
|
170
|
-
getCurrentState,
|
|
171
|
-
setCurrentState,
|
|
172
|
-
getKey,
|
|
173
|
-
setKey,
|
|
174
|
-
getIsInitial,
|
|
175
|
-
addOptionsGetter,
|
|
176
|
-
]
|
|
167
|
+
[routeState, getCurrentState, setCurrentState, getKey, setKey, getIsInitial]
|
|
177
168
|
);
|
|
178
169
|
|
|
179
170
|
const ScreenComponent = screen.getComponent
|
|
180
|
-
?
|
|
171
|
+
? // eslint-disable-next-line @eslint-react/static-components
|
|
172
|
+
screen.getComponent()
|
|
181
173
|
: screen.component;
|
|
182
174
|
|
|
183
175
|
return (
|
|
184
176
|
<NavigationStateContext.Provider value={context}>
|
|
185
177
|
<NavigationFocusedRouteStateContext.Provider value={focusedRouteState}>
|
|
186
|
-
<
|
|
187
|
-
<
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
178
|
+
<OptionsGetterContext.Provider value={addOptionsGetter}>
|
|
179
|
+
<EnsureSingleNavigator>
|
|
180
|
+
<StaticContainer
|
|
181
|
+
name={screen.name}
|
|
182
|
+
render={ScreenComponent || screen.children}
|
|
183
|
+
navigation={navigation}
|
|
184
|
+
route={route}
|
|
185
|
+
>
|
|
186
|
+
{ScreenComponent !== undefined ? (
|
|
187
|
+
// eslint-disable-next-line @eslint-react/static-components
|
|
188
|
+
<ScreenComponent navigation={navigation} route={route} />
|
|
189
|
+
) : screen.children !== undefined ? (
|
|
190
|
+
screen.children({ navigation, route })
|
|
191
|
+
) : null}
|
|
192
|
+
</StaticContainer>
|
|
193
|
+
</EnsureSingleNavigator>
|
|
194
|
+
</OptionsGetterContext.Provider>
|
|
200
195
|
</NavigationFocusedRouteStateContext.Provider>
|
|
201
196
|
</NavigationStateContext.Provider>
|
|
202
197
|
);
|