@react-navigation/core 7.5.0 → 7.6.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.
- package/lib/commonjs/StaticNavigation.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +39 -33
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useComponent.d.ts +1 -1
- package/lib/typescript/commonjs/src/useComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useDescriptors.d.ts +24 -18
- package/lib/typescript/commonjs/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useNavigationBuilder.d.ts +36 -27
- package/lib/typescript/commonjs/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useNavigationCache.d.ts +12 -9
- package/lib/typescript/commonjs/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/useNavigationHelpers.d.ts +12 -9
- package/lib/typescript/commonjs/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +39 -33
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/useComponent.d.ts +1 -1
- package/lib/typescript/module/src/useComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/useDescriptors.d.ts +24 -18
- package/lib/typescript/module/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/module/src/useNavigationBuilder.d.ts +36 -27
- package/lib/typescript/module/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/module/src/useNavigationCache.d.ts +12 -9
- package/lib/typescript/module/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/module/src/useNavigationHelpers.d.ts +12 -9
- package/lib/typescript/module/src/useNavigationHelpers.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/StaticNavigation.tsx +1 -1
- package/src/types.tsx +53 -51
- package/src/useComponent.tsx +1 -1
package/src/types.tsx
CHANGED
|
@@ -23,21 +23,6 @@ declare global {
|
|
|
23
23
|
|
|
24
24
|
type Keyof<T extends {}> = Extract<keyof T, string>;
|
|
25
25
|
|
|
26
|
-
type ScreenParamsPair<
|
|
27
|
-
ParamList extends ParamListBase,
|
|
28
|
-
RouteName extends keyof ParamList,
|
|
29
|
-
> = {
|
|
30
|
-
// First we use a mapped type to get an union of screen & params pairs
|
|
31
|
-
// Then we pick the pair which matches the RouteName
|
|
32
|
-
// Mapped type is used instead of just ParamList[RouteName]
|
|
33
|
-
// Otherwise it'll result in union of all params leading to incorrect types
|
|
34
|
-
[Screen in keyof ParamList]: undefined extends ParamList[Screen] // Params are either undefined or a union with undefined
|
|
35
|
-
?
|
|
36
|
-
| [screen: Screen] // if the params are optional, we don't have to provide it
|
|
37
|
-
| [screen: Screen, params: ParamList[Screen]]
|
|
38
|
-
: [screen: Screen, params: ParamList[Screen]];
|
|
39
|
-
}[RouteName];
|
|
40
|
-
|
|
41
26
|
export type DefaultNavigatorOptions<
|
|
42
27
|
ParamList extends ParamListBase,
|
|
43
28
|
NavigatorID extends string | undefined,
|
|
@@ -110,7 +95,7 @@ export type DefaultNavigatorOptions<
|
|
|
110
95
|
|
|
111
96
|
/**
|
|
112
97
|
* A function returning overrides for the underlying router used by the navigator.
|
|
113
|
-
* The overrides will be shallow merged
|
|
98
|
+
* The overrides will be shallow merged onto the original router.
|
|
114
99
|
* It receives the original router as an argument to the function.
|
|
115
100
|
*
|
|
116
101
|
* This must be a pure function and cannot reference outside dynamic variables.
|
|
@@ -256,21 +241,30 @@ type NavigationHelpersCommon<
|
|
|
256
241
|
* Navigate to a screen in the current or parent navigator.
|
|
257
242
|
* If we're already on the screen, update the params instead.
|
|
258
243
|
*
|
|
259
|
-
* @param
|
|
244
|
+
* @param screen Name of the route to navigate to.
|
|
260
245
|
* @param [params] Params object for the route.
|
|
261
|
-
* @param [merge] Whether to merge the params onto the route.
|
|
246
|
+
* @param [options.merge] Whether to merge the params onto the route. Defaults to `false`.
|
|
247
|
+
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route. Defaults to `false`.
|
|
262
248
|
*/
|
|
263
249
|
navigate<RouteName extends keyof ParamList>(
|
|
264
|
-
...args:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
250
|
+
...args: // This condition allows us to iterate over a union type
|
|
251
|
+
// This is to avoid getting a union of all the params from `ParamList[RouteName]`,
|
|
252
|
+
// which will get our types all mixed up if a union RouteName is passed in.
|
|
253
|
+
RouteName extends unknown
|
|
254
|
+
? // This condition checks if the params are optional,
|
|
255
|
+
// which means it's either undefined or a union with undefined
|
|
256
|
+
undefined extends ParamList[RouteName]
|
|
257
|
+
? [
|
|
258
|
+
screen: RouteName,
|
|
259
|
+
params?: ParamList[RouteName],
|
|
260
|
+
options?: { merge?: boolean; pop?: boolean },
|
|
261
|
+
]
|
|
262
|
+
: [
|
|
263
|
+
screen: RouteName,
|
|
264
|
+
params: ParamList[RouteName],
|
|
265
|
+
options?: { merge?: boolean; pop?: boolean },
|
|
266
|
+
]
|
|
267
|
+
: never
|
|
274
268
|
): void;
|
|
275
269
|
|
|
276
270
|
/**
|
|
@@ -279,19 +273,19 @@ type NavigationHelpersCommon<
|
|
|
279
273
|
* @param options.name Name of the route to navigate to.
|
|
280
274
|
* @param [options.params] Params object for the route.
|
|
281
275
|
* @param [options.path] Path to associate the route with (e.g. for deep links).
|
|
282
|
-
* @param [options.merge] Whether to merge the params onto the route.
|
|
283
|
-
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route.
|
|
276
|
+
* @param [options.merge] Whether to merge the params onto the route. Defaults to `false`.
|
|
277
|
+
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route. Defaults to `false`.
|
|
284
278
|
*/
|
|
285
279
|
navigate<RouteName extends keyof ParamList>(
|
|
286
|
-
options:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
280
|
+
options: RouteName extends unknown
|
|
281
|
+
? {
|
|
282
|
+
name: RouteName;
|
|
283
|
+
params: ParamList[RouteName];
|
|
284
|
+
path?: string;
|
|
285
|
+
merge?: boolean;
|
|
286
|
+
pop?: boolean;
|
|
287
|
+
}
|
|
288
|
+
: never
|
|
295
289
|
): void;
|
|
296
290
|
|
|
297
291
|
/**
|
|
@@ -299,11 +293,15 @@ type NavigationHelpersCommon<
|
|
|
299
293
|
*
|
|
300
294
|
* @deprecated Use `navigate` instead.
|
|
301
295
|
*
|
|
302
|
-
* @param
|
|
296
|
+
* @param screen Name of the route to navigate to.
|
|
303
297
|
* @param [params] Params object for the route.
|
|
304
298
|
*/
|
|
305
299
|
navigateDeprecated<RouteName extends keyof ParamList>(
|
|
306
|
-
...args:
|
|
300
|
+
...args: RouteName extends unknown
|
|
301
|
+
? undefined extends ParamList[RouteName]
|
|
302
|
+
? [screen: RouteName, params?: ParamList[RouteName]]
|
|
303
|
+
: [screen: RouteName, params: ParamList[RouteName]]
|
|
304
|
+
: never
|
|
307
305
|
): void;
|
|
308
306
|
|
|
309
307
|
/**
|
|
@@ -314,23 +312,27 @@ type NavigationHelpersCommon<
|
|
|
314
312
|
* @param options Object with `name` for the route to navigate to, and a `params` object.
|
|
315
313
|
*/
|
|
316
314
|
navigateDeprecated<RouteName extends keyof ParamList>(
|
|
317
|
-
options:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
315
|
+
options: RouteName extends unknown
|
|
316
|
+
? {
|
|
317
|
+
name: RouteName;
|
|
318
|
+
params: ParamList[RouteName];
|
|
319
|
+
merge?: boolean;
|
|
320
|
+
}
|
|
321
|
+
: never
|
|
324
322
|
): void;
|
|
325
323
|
|
|
326
324
|
/**
|
|
327
325
|
* Preloads the route in current navigation tree.
|
|
328
326
|
*
|
|
329
|
-
* @param
|
|
327
|
+
* @param screen Name of the route to preload.
|
|
330
328
|
* @param [params] Params object for the route.
|
|
331
329
|
*/
|
|
332
330
|
preload<RouteName extends keyof ParamList>(
|
|
333
|
-
...args:
|
|
331
|
+
...args: RouteName extends unknown
|
|
332
|
+
? undefined extends ParamList[RouteName]
|
|
333
|
+
? [screen: RouteName, params?: ParamList[RouteName]]
|
|
334
|
+
: [screen: RouteName, params: ParamList[RouteName]]
|
|
335
|
+
: never
|
|
334
336
|
): void;
|
|
335
337
|
|
|
336
338
|
/**
|
|
@@ -549,7 +551,7 @@ export type Descriptor<
|
|
|
549
551
|
/**
|
|
550
552
|
* Render the component associated with this route.
|
|
551
553
|
*/
|
|
552
|
-
render(): JSX.Element;
|
|
554
|
+
render(): React.JSX.Element;
|
|
553
555
|
|
|
554
556
|
/**
|
|
555
557
|
* Options for the route.
|