@react-navigation/native 7.0.0-rc.17 → 7.0.0-rc.19
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/commonjs/createStaticNavigation.js +24 -16
- package/lib/commonjs/createStaticNavigation.js.map +1 -1
- package/lib/module/createStaticNavigation.js +24 -16
- package/lib/module/createStaticNavigation.js.map +1 -1
- package/lib/typescript/commonjs/src/createStaticNavigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useLinkProps.d.ts +9 -7
- package/lib/typescript/commonjs/src/useLinkProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/createStaticNavigation.d.ts.map +1 -1
- package/lib/typescript/module/src/useLinkProps.d.ts +9 -7
- package/lib/typescript/module/src/useLinkProps.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/createStaticNavigation.tsx +38 -26
- package/src/useLinkProps.tsx +5 -5
|
@@ -51,19 +51,46 @@ export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
|
51
51
|
{ linking, ...rest }: Props,
|
|
52
52
|
ref: React.Ref<NavigationContainerRef<ParamListBase>>
|
|
53
53
|
) {
|
|
54
|
-
const
|
|
55
|
-
if (tree.config.screens)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
const linkingConfig = React.useMemo(() => {
|
|
55
|
+
if (!tree.config.screens) return;
|
|
56
|
+
|
|
57
|
+
const screens = createPathConfigForStaticNavigation(
|
|
58
|
+
tree,
|
|
59
|
+
{ initialRouteName: linking?.config?.initialRouteName },
|
|
60
|
+
linking?.enabled === 'auto'
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!screens) return;
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
path: linking?.config?.path,
|
|
67
|
+
initialRouteName: linking?.config?.initialRouteName,
|
|
68
|
+
screens,
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
linking?.enabled,
|
|
72
|
+
linking?.config?.path,
|
|
73
|
+
linking?.config?.initialRouteName,
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
const memoizedLinking = React.useMemo(() => {
|
|
77
|
+
if (!linking) {
|
|
78
|
+
return undefined;
|
|
61
79
|
}
|
|
62
80
|
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
const enabled =
|
|
82
|
+
typeof linking.enabled === 'boolean'
|
|
83
|
+
? linking.enabled
|
|
84
|
+
: linkingConfig?.screens != null;
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
...linking,
|
|
88
|
+
enabled,
|
|
89
|
+
config: linkingConfig,
|
|
90
|
+
};
|
|
91
|
+
}, [linking, linkingConfig]);
|
|
65
92
|
|
|
66
|
-
if (linking?.enabled === true && screens == null) {
|
|
93
|
+
if (linking?.enabled === true && linkingConfig?.screens == null) {
|
|
67
94
|
throw new Error(
|
|
68
95
|
'Linking is enabled but no linking configuration was found for the screens.\n\n' +
|
|
69
96
|
'To solve this:\n' +
|
|
@@ -74,22 +101,7 @@ export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
|
74
101
|
}
|
|
75
102
|
|
|
76
103
|
return (
|
|
77
|
-
<NavigationContainer
|
|
78
|
-
{...rest}
|
|
79
|
-
ref={ref}
|
|
80
|
-
linking={
|
|
81
|
-
linking
|
|
82
|
-
? {
|
|
83
|
-
...linking,
|
|
84
|
-
enabled:
|
|
85
|
-
typeof linking.enabled === 'boolean'
|
|
86
|
-
? linking.enabled
|
|
87
|
-
: screens != null,
|
|
88
|
-
config: screens ? { ...linking.config, screens } : undefined,
|
|
89
|
-
}
|
|
90
|
-
: undefined
|
|
91
|
-
}
|
|
92
|
-
>
|
|
104
|
+
<NavigationContainer {...rest} ref={ref} linking={memoizedLinking}>
|
|
93
105
|
<Component />
|
|
94
106
|
</NavigationContainer>
|
|
95
107
|
);
|
package/src/useLinkProps.tsx
CHANGED
|
@@ -19,11 +19,11 @@ export type LinkProps<
|
|
|
19
19
|
| ({
|
|
20
20
|
href?: string;
|
|
21
21
|
action?: NavigationAction;
|
|
22
|
-
} &
|
|
23
|
-
|
|
24
|
-
? { screen:
|
|
25
|
-
: { screen:
|
|
26
|
-
|
|
22
|
+
} & {
|
|
23
|
+
[Screen in keyof ParamList]: undefined extends ParamList[Screen]
|
|
24
|
+
? { screen: Screen; params?: ParamList[Screen] }
|
|
25
|
+
: { screen: Screen; params: ParamList[Screen] };
|
|
26
|
+
}[RouteName])
|
|
27
27
|
| {
|
|
28
28
|
href?: string;
|
|
29
29
|
action: NavigationAction;
|