@react-navigation/core 7.13.7 → 8.0.0-alpha.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 +4 -9
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +12 -7
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +49 -0
- package/lib/module/NavigationProvider.js.map +1 -0
- package/lib/module/PreventRemoveProvider.js +1 -1
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/StaticNavigation.js +32 -21
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/getActionFromState.js +3 -2
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getPathFromState.js +1 -1
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +3 -3
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/theming/ThemeContext.js.map +1 -1
- package/lib/module/theming/ThemeProvider.js.map +1 -1
- package/lib/module/theming/useTheme.js +1 -1
- package/lib/module/theming/useTheme.js.map +1 -1
- package/lib/module/types.js +41 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useChildListeners.js +2 -4
- package/lib/module/useChildListeners.js.map +1 -1
- package/lib/module/useDescriptors.js +5 -9
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +9 -20
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEvents.js +1 -1
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useNavigation.js +31 -8
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +10 -12
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +18 -11
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +2 -14
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationState.js +42 -9
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +2 -7
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetState.js +1 -1
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +1 -1
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useRoute.js +23 -5
- package/lib/module/useRoute.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +1 -2
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/module/useSyncState.js +25 -9
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/module/utilities.js +2 -0
- package/lib/module/utilities.js.map +1 -0
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts +44 -0
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -0
- package/lib/typescript/src/SceneView.d.ts +1 -1
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +231 -80
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts +2 -2
- package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts +2 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts +2 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +188 -133
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +27 -109
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +7 -5
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +25 -114
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +8 -22
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts +2 -2
- package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +3 -11
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +10 -3
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/useRoute.d.ts +8 -2
- package/lib/typescript/src/useRoute.d.ts.map +1 -1
- package/lib/typescript/src/useRouteCache.d.ts +12 -3
- package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts.map +1 -1
- package/lib/typescript/src/utilities.d.ts +99 -0
- package/lib/typescript/src/utilities.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/BaseNavigationContainer.tsx +3 -9
- package/src/NavigationIndependentTree.tsx +17 -9
- package/src/NavigationProvider.tsx +64 -0
- package/src/PreventRemoveProvider.tsx +1 -1
- package/src/SceneView.tsx +1 -7
- package/src/StaticNavigation.tsx +372 -134
- package/src/createNavigationContainerRef.tsx +2 -1
- package/src/getActionFromState.tsx +4 -2
- package/src/getPathFromState.tsx +6 -5
- package/src/getStateFromPath.tsx +11 -11
- package/src/index.tsx +8 -4
- package/src/theming/ThemeContext.tsx +3 -3
- package/src/theming/ThemeProvider.tsx +2 -1
- package/src/theming/useTheme.tsx +1 -1
- package/src/types.tsx +392 -243
- package/src/useChildListeners.tsx +3 -2
- package/src/useDescriptors.tsx +11 -17
- package/src/useEventEmitter.tsx +14 -31
- package/src/useFocusEvents.tsx +1 -1
- package/src/useNavigation.tsx +57 -14
- package/src/useNavigationBuilder.tsx +10 -13
- package/src/useNavigationCache.tsx +40 -18
- package/src/useNavigationContainerRef.tsx +2 -2
- package/src/useNavigationHelpers.tsx +2 -19
- package/src/useNavigationState.tsx +90 -19
- package/src/useOnAction.tsx +1 -12
- package/src/useOnGetState.tsx +1 -1
- package/src/useOnPreventRemove.tsx +1 -1
- package/src/useRoute.tsx +52 -7
- package/src/useScheduleUpdate.tsx +1 -2
- package/src/useSyncState.tsx +28 -13
- package/src/utilities.tsx +122 -0
- package/lib/module/DeprecatedNavigationInChildContext.js +0 -9
- package/lib/module/DeprecatedNavigationInChildContext.js.map +0 -1
- package/lib/module/NavigationContext.js +0 -8
- package/lib/module/NavigationContext.js.map +0 -1
- package/lib/module/NavigationRouteContext.js +0 -9
- package/lib/module/NavigationRouteContext.js.map +0 -1
- package/lib/module/useClientLayoutEffect.js +0 -9
- package/lib/module/useClientLayoutEffect.js.map +0 -1
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts +0 -6
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationContext.d.ts +0 -8
- package/lib/typescript/src/NavigationContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationRouteContext.d.ts +0 -7
- package/lib/typescript/src/NavigationRouteContext.d.ts.map +0 -1
- package/lib/typescript/src/useClientLayoutEffect.d.ts +0 -6
- package/lib/typescript/src/useClientLayoutEffect.d.ts.map +0 -1
- package/src/DeprecatedNavigationInChildContext.tsx +0 -6
- package/src/NavigationContext.tsx +0 -11
- package/src/NavigationRouteContext.tsx +0 -9
- package/src/useClientLayoutEffect.tsx +0 -10
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NavigationState
|
|
2
|
-
import type { RouteProp } from './types';
|
|
1
|
+
import type { NavigationState } from '@react-navigation/routers';
|
|
3
2
|
/**
|
|
4
3
|
* Utilities such as `getFocusedRouteNameFromRoute` need to access state.
|
|
5
4
|
* So we need a way to suppress the warning for those use cases.
|
|
@@ -10,5 +9,15 @@ export declare const CHILD_STATE: unique symbol;
|
|
|
10
9
|
* Hook to cache route props for each screen in the navigator.
|
|
11
10
|
* This lets add warnings and modifications to the route object but keep references between renders.
|
|
12
11
|
*/
|
|
13
|
-
export declare function useRouteCache<State extends NavigationState>(routes: State['routes']):
|
|
12
|
+
export declare function useRouteCache<State extends NavigationState>(routes: State['routes']): Readonly<{
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
history?: {
|
|
17
|
+
type: "params";
|
|
18
|
+
params: object;
|
|
19
|
+
}[];
|
|
20
|
+
} & Readonly<{
|
|
21
|
+
params?: Readonly<object | undefined>;
|
|
22
|
+
}>>[];
|
|
14
23
|
//# sourceMappingURL=useRouteCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouteCache.d.ts","sourceRoot":"","sources":["../../../src/useRouteCache.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"useRouteCache.d.ts","sourceRoot":"","sources":["../../../src/useRouteCache.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,2BAA2B,CAAC;AAQhF;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAwB,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,eAAe,EACzD,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;;;;;;;;;;MA8CxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScheduleUpdate.d.ts","sourceRoot":"","sources":["../../../src/useScheduleUpdate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useScheduleUpdate.d.ts","sourceRoot":"","sources":["../../../src/useScheduleUpdate.tsx"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,QAUrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncState.d.ts","sourceRoot":"","sources":["../../../src/useSyncState.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSyncState.d.ts","sourceRoot":"","sources":["../../../src/useSyncState.tsx"],"names":[],"mappings":"AA8DA,wBAAgB,YAAY,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC;;;;wCA6BF,MAAM,IAAI;;EA4B/D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flatten a type to remove all type alias names, unions etc.
|
|
3
|
+
* This will show a plain object when hovering over the type.
|
|
4
|
+
*/
|
|
5
|
+
export type FlatType<T> = {
|
|
6
|
+
[K in keyof T]: T[K];
|
|
7
|
+
} & {};
|
|
8
|
+
/**
|
|
9
|
+
* keyof T doesn't work for union types. We can use distributive conditional types instead.
|
|
10
|
+
* https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
|
11
|
+
*/
|
|
12
|
+
export type KeysOf<T> = T extends {} ? keyof T : never;
|
|
13
|
+
/**
|
|
14
|
+
* Extract string keys from an object type.
|
|
15
|
+
*/
|
|
16
|
+
export type KeyOf<T extends {}> = Extract<keyof T, string>;
|
|
17
|
+
/**
|
|
18
|
+
* We get a union type when using keyof, but we want an intersection instead.
|
|
19
|
+
* https://stackoverflow.com/a/50375286/1665026
|
|
20
|
+
*/
|
|
21
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
22
|
+
export type UnknownToUndefined<T> = unknown extends T ? undefined : T;
|
|
23
|
+
/**
|
|
24
|
+
* Exclude undefined from a type.
|
|
25
|
+
* Similar to NonNullable but only excludes undefined, not null.
|
|
26
|
+
*/
|
|
27
|
+
export type NotUndefined<T> = T extends undefined ? never : T;
|
|
28
|
+
export type AnyToUnknown<T> = 0 extends 1 & T ? unknown : T;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a function type has arguments.
|
|
31
|
+
*/
|
|
32
|
+
export type HasArguments<T extends (...args: any[]) => any> = Parameters<T> extends [] ? false : Parameters<T> extends [undefined?] ? false : true;
|
|
33
|
+
export type ValidPathPattern = `:${string}` | `${string}/:${string}`;
|
|
34
|
+
/**
|
|
35
|
+
* Strip regex pattern from a path param.
|
|
36
|
+
* e.g. `userId([a-z]+)` -> `userId`
|
|
37
|
+
*/
|
|
38
|
+
type StripRegex<Param extends string> = Param extends `${infer Name}(${string})` ? Name : Param;
|
|
39
|
+
/**
|
|
40
|
+
* Extract a single path param from a segment.
|
|
41
|
+
* e.g. `:userId` -> `{ userId: string }`, `:id?` -> `{ id?: string }`
|
|
42
|
+
*/
|
|
43
|
+
type ExtractSegmentParam<Segment extends string> = Segment extends `:${infer Param}?` ? {
|
|
44
|
+
[K in StripRegex<Param>]?: string;
|
|
45
|
+
} : Segment extends `:${infer Param}` ? {
|
|
46
|
+
[K in StripRegex<Param>]: string;
|
|
47
|
+
} : {};
|
|
48
|
+
/**
|
|
49
|
+
* Extract path params from a path string.
|
|
50
|
+
* e.g. `/foo/:userId/:postId` -> `{ userId: string; postId: string }`
|
|
51
|
+
* Supports optional params with `?` suffix.
|
|
52
|
+
* Params must start with `:` at the beginning of a segment (after `/`).
|
|
53
|
+
*/
|
|
54
|
+
export type ExtractParamStrings<Path extends string> = Path extends `${infer Segment}/${infer Rest}` ? ExtractSegmentParam<Segment> & ExtractParamStrings<Rest> : ExtractSegmentParam<Path>;
|
|
55
|
+
/**
|
|
56
|
+
* Extract the parsed params type from base params and parse functions.
|
|
57
|
+
* Applies the return type of parse functions to the corresponding params.
|
|
58
|
+
*/
|
|
59
|
+
export type ExtractParamsType<Params, Parse> = {
|
|
60
|
+
[K in keyof Params]: K extends keyof Parse ? Parse[K] extends (value: string) => infer R ? R : Params[K] : Params[K];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Infer the path string from a linking config.
|
|
64
|
+
*/
|
|
65
|
+
export type InferPath<T> = T extends {
|
|
66
|
+
path: infer P extends string;
|
|
67
|
+
} ? P : never;
|
|
68
|
+
/**
|
|
69
|
+
* Infer the parse functions from a linking config.
|
|
70
|
+
*/
|
|
71
|
+
export type InferParse<T> = T extends {
|
|
72
|
+
parse: infer P;
|
|
73
|
+
} ? P : {};
|
|
74
|
+
/**
|
|
75
|
+
* Infer the params type from a screen component or nested navigator.
|
|
76
|
+
*/
|
|
77
|
+
export type InferScreenParams<T> = T extends React.ComponentType<{
|
|
78
|
+
route: {
|
|
79
|
+
params: infer P;
|
|
80
|
+
};
|
|
81
|
+
}> ? P : T extends {
|
|
82
|
+
config: {
|
|
83
|
+
screens: infer Screens;
|
|
84
|
+
};
|
|
85
|
+
} ? import('./types').NavigatorScreenParams<{
|
|
86
|
+
[K in keyof Screens]: Screens[K] extends React.ComponentType<{
|
|
87
|
+
route: {
|
|
88
|
+
params: infer P;
|
|
89
|
+
};
|
|
90
|
+
}> ? P : Screens[K] extends {
|
|
91
|
+
screen: infer S;
|
|
92
|
+
} ? S extends React.ComponentType<{
|
|
93
|
+
route: {
|
|
94
|
+
params: infer P;
|
|
95
|
+
};
|
|
96
|
+
}> ? P : undefined : undefined;
|
|
97
|
+
}> : undefined;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../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CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,EAAE,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC7B,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC;IAAE,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC,GACzD,CAAC,GACD,CAAC,SAAS;IAAE,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,OAAO,CAAA;KAAE,CAAA;CAAE,GAC9C,OAAO,SAAS,EAAE,qBAAqB,CAAC;KACrC,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC;QAC3D,KAAK,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,CAAC;KAC5B,CAAC,GACE,CAAC,GACD,OAAO,CAAC,CAAC,CAAC,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GACpC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,CAAA;KAAE,CAAC,GAC3D,CAAC,GACD,SAAS,GACX,SAAS;CAChB,CAAC,GACF,SAAS,CAAC"}
|
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": "
|
|
4
|
+
"version": "8.0.0-alpha.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"react-native",
|
|
@@ -40,30 +40,30 @@
|
|
|
40
40
|
"clean": "del lib"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@react-navigation/routers": "^
|
|
43
|
+
"@react-navigation/routers": "^8.0.0-alpha.0",
|
|
44
44
|
"escape-string-regexp": "^4.0.0",
|
|
45
45
|
"fast-deep-equal": "^3.1.3",
|
|
46
46
|
"nanoid": "^3.3.11",
|
|
47
47
|
"query-string": "^7.1.3",
|
|
48
48
|
"react-is": "^19.1.0",
|
|
49
|
-
"use-latest-callback": "^0.2
|
|
49
|
+
"use-latest-callback": "^0.3.2",
|
|
50
50
|
"use-sync-external-store": "^1.5.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@jest/globals": "^30.0.0",
|
|
54
54
|
"@testing-library/react-native": "^13.2.1",
|
|
55
|
-
"@types/react": "~19.
|
|
55
|
+
"@types/react": "~19.1.10",
|
|
56
56
|
"@types/react-is": "^19.0.0",
|
|
57
57
|
"@types/use-sync-external-store": "^1.5.0",
|
|
58
58
|
"del-cli": "^6.0.0",
|
|
59
59
|
"immer": "^10.1.1",
|
|
60
60
|
"react": "19.1.0",
|
|
61
|
-
"react-native-builder-bob": "^0.40.
|
|
61
|
+
"react-native-builder-bob": "^0.40.12",
|
|
62
62
|
"react-test-renderer": "19.1.0",
|
|
63
63
|
"typescript": "^5.9.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"react": ">=
|
|
66
|
+
"react": ">= 19.0.0"
|
|
67
67
|
},
|
|
68
68
|
"react-native-builder-bob": {
|
|
69
69
|
"source": "src",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "46daae524ec6a59737147ed506222dd09a5b6e39"
|
|
87
87
|
}
|
|
@@ -13,7 +13,6 @@ import useLatestCallback from 'use-latest-callback';
|
|
|
13
13
|
import { checkDuplicateRouteNames } from './checkDuplicateRouteNames';
|
|
14
14
|
import { checkSerializable } from './checkSerializable';
|
|
15
15
|
import { NOT_INITIALIZED_ERROR } from './createNavigationContainerRef';
|
|
16
|
-
import { DeprecatedNavigationInChildContext } from './DeprecatedNavigationInChildContext';
|
|
17
16
|
import { EnsureSingleNavigator } from './EnsureSingleNavigator';
|
|
18
17
|
import { findFocusedRoute } from './findFocusedRoute';
|
|
19
18
|
import { NavigationBuilderContext } from './NavigationBuilderContext';
|
|
@@ -88,7 +87,6 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
88
87
|
onStateChange,
|
|
89
88
|
onReady,
|
|
90
89
|
onUnhandledAction,
|
|
91
|
-
navigationInChildEnabled = false,
|
|
92
90
|
theme,
|
|
93
91
|
children,
|
|
94
92
|
}: NavigationContainerProps,
|
|
@@ -450,13 +448,9 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
450
448
|
<UnhandledActionContext.Provider
|
|
451
449
|
value={onUnhandledAction ?? defaultOnUnhandledAction}
|
|
452
450
|
>
|
|
453
|
-
<
|
|
454
|
-
value={
|
|
455
|
-
>
|
|
456
|
-
<EnsureSingleNavigator>
|
|
457
|
-
<ThemeProvider value={theme}>{children}</ThemeProvider>
|
|
458
|
-
</EnsureSingleNavigator>
|
|
459
|
-
</DeprecatedNavigationInChildContext.Provider>
|
|
451
|
+
<EnsureSingleNavigator>
|
|
452
|
+
<ThemeProvider value={theme}>{children}</ThemeProvider>
|
|
453
|
+
</EnsureSingleNavigator>
|
|
460
454
|
</UnhandledActionContext.Provider>
|
|
461
455
|
</NavigationStateContext.Provider>
|
|
462
456
|
</NavigationBuilderContext.Provider>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { NavigationContext } from './NavigationContext';
|
|
4
3
|
import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
NamedRouteContextListContext,
|
|
6
|
+
NavigationContext,
|
|
7
|
+
NavigationRouteContext,
|
|
8
|
+
NavigationRouteNameContext,
|
|
9
|
+
} from './NavigationProvider';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Component to make the child navigation container independent of parent containers.
|
|
@@ -14,12 +18,16 @@ export function NavigationIndependentTree({
|
|
|
14
18
|
}) {
|
|
15
19
|
return (
|
|
16
20
|
// We need to clear any existing contexts for nested independent container to work correctly
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
<NamedRouteContextListContext.Provider value={undefined}>
|
|
22
|
+
<NavigationRouteContext.Provider value={undefined}>
|
|
23
|
+
<NavigationContext.Provider value={undefined}>
|
|
24
|
+
<NavigationRouteNameContext.Provider value={undefined}>
|
|
25
|
+
<NavigationIndependentTreeContext.Provider value={true}>
|
|
26
|
+
{children}
|
|
27
|
+
</NavigationIndependentTreeContext.Provider>
|
|
28
|
+
</NavigationRouteNameContext.Provider>
|
|
29
|
+
</NavigationContext.Provider>
|
|
30
|
+
</NavigationRouteContext.Provider>
|
|
31
|
+
</NamedRouteContextListContext.Provider>
|
|
24
32
|
);
|
|
25
33
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ParamListBase, Route } from '@react-navigation/routers';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import type { NavigationProp } from './types';
|
|
5
|
+
import { useLazyValue } from './useLazyValue';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Context which holds the route prop for a screen.
|
|
9
|
+
*/
|
|
10
|
+
export const NavigationRouteContext = React.createContext<
|
|
11
|
+
Route<string> | undefined
|
|
12
|
+
>(undefined);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Context which holds the navigation prop for a screen.
|
|
16
|
+
*/
|
|
17
|
+
export const NavigationContext = React.createContext<
|
|
18
|
+
NavigationProp<ParamListBase> | undefined
|
|
19
|
+
>(undefined);
|
|
20
|
+
|
|
21
|
+
export const NavigationRouteNameContext = React.createContext<
|
|
22
|
+
string | undefined
|
|
23
|
+
>(undefined);
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
route: Route<string>;
|
|
27
|
+
navigation: NavigationProp<ParamListBase>;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Component to provide the navigation and route contexts to its children.
|
|
33
|
+
*/
|
|
34
|
+
export const NamedRouteContextListContext = React.createContext<
|
|
35
|
+
Record<string, React.Context<Route<string>>> | undefined
|
|
36
|
+
>(undefined);
|
|
37
|
+
|
|
38
|
+
export function NavigationProvider({ route, navigation, children }: Props) {
|
|
39
|
+
const NamedRouteContext = useLazyValue(() => React.createContext(route));
|
|
40
|
+
|
|
41
|
+
const parents = React.use(NamedRouteContextListContext);
|
|
42
|
+
|
|
43
|
+
const NamedRouteContextList = React.useMemo(
|
|
44
|
+
() => ({
|
|
45
|
+
...parents,
|
|
46
|
+
[route.name]: NamedRouteContext,
|
|
47
|
+
}),
|
|
48
|
+
[NamedRouteContext, parents, route.name]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<NamedRouteContextListContext.Provider value={NamedRouteContextList}>
|
|
53
|
+
<NamedRouteContext.Provider value={route}>
|
|
54
|
+
<NavigationRouteContext.Provider value={route}>
|
|
55
|
+
<NavigationContext.Provider value={navigation}>
|
|
56
|
+
<NavigationRouteNameContext.Provider value={route.name}>
|
|
57
|
+
{children}
|
|
58
|
+
</NavigationRouteNameContext.Provider>
|
|
59
|
+
</NavigationContext.Provider>
|
|
60
|
+
</NavigationRouteContext.Provider>
|
|
61
|
+
</NamedRouteContext.Provider>
|
|
62
|
+
</NamedRouteContextListContext.Provider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import useLatestCallback from 'use-latest-callback';
|
|
4
4
|
|
|
5
5
|
import { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
6
|
-
import { NavigationRouteContext } from './
|
|
6
|
+
import { NavigationRouteContext } from './NavigationProvider';
|
|
7
7
|
import {
|
|
8
8
|
type PreventedRoutes,
|
|
9
9
|
PreventRemoveContext,
|
package/src/SceneView.tsx
CHANGED
|
@@ -19,13 +19,7 @@ import { useOptionsGetters } from './useOptionsGetters';
|
|
|
19
19
|
|
|
20
20
|
type Props<State extends NavigationState, ScreenOptions extends {}> = {
|
|
21
21
|
screen: RouteConfigComponent<ParamListBase, string> & { name: string };
|
|
22
|
-
navigation: NavigationProp<
|
|
23
|
-
ParamListBase,
|
|
24
|
-
string,
|
|
25
|
-
string | undefined,
|
|
26
|
-
State,
|
|
27
|
-
ScreenOptions
|
|
28
|
-
>;
|
|
22
|
+
navigation: NavigationProp<ParamListBase, string, State, ScreenOptions>;
|
|
29
23
|
route: Route<string>;
|
|
30
24
|
routeState: NavigationState | PartialState<NavigationState> | undefined;
|
|
31
25
|
getState: () => State;
|