@react-navigation/core
Advanced tools
Comparing version
@@ -31,2 +31,20 @@ "use strict"; | ||
} : undefined; | ||
// If the screen contains a navigator, pop other screens to navigate to it | ||
// This avoid pushing multiple instances of navigators onto a stack | ||
// | ||
// For example: | ||
// - RootStack | ||
// - BottomTabs | ||
// - SomeScreen | ||
// | ||
// In this case, if deep linking to `BottomTabs`, we should pop `SomeScreen` | ||
// Otherwise, we'll end up with 2 instances of `BottomTabs` in the stack | ||
// | ||
// There are 2 ways we can detect if a screen contains a navigator: | ||
// - The route contains nested state in `route.state` | ||
// - Nested screens are defined in the config | ||
if (payload && config?.screens && Object.keys(config.screens).length) { | ||
payload.pop = true; | ||
} | ||
while (current) { | ||
@@ -60,2 +78,3 @@ if (current.routes.length === 0) { | ||
}; | ||
params.pop = true; | ||
params = params.params; | ||
@@ -68,3 +87,9 @@ } else { | ||
config = config?.screens?.[route.name]; | ||
if (config?.screens && Object.keys(config.screens).length) { | ||
params.pop = true; | ||
} | ||
} | ||
if (payload?.params.screen || payload?.params.state) { | ||
payload.pop = true; | ||
} | ||
if (!payload) { | ||
@@ -71,0 +96,0 @@ return; |
@@ -291,3 +291,4 @@ "use strict"; | ||
params: route.params.params, | ||
path: route.params.path | ||
path: route.params.path, | ||
pop: route.params.pop | ||
}); | ||
@@ -294,0 +295,0 @@ } |
@@ -27,2 +27,20 @@ "use strict"; | ||
} : undefined; | ||
// If the screen contains a navigator, pop other screens to navigate to it | ||
// This avoid pushing multiple instances of navigators onto a stack | ||
// | ||
// For example: | ||
// - RootStack | ||
// - BottomTabs | ||
// - SomeScreen | ||
// | ||
// In this case, if deep linking to `BottomTabs`, we should pop `SomeScreen` | ||
// Otherwise, we'll end up with 2 instances of `BottomTabs` in the stack | ||
// | ||
// There are 2 ways we can detect if a screen contains a navigator: | ||
// - The route contains nested state in `route.state` | ||
// - Nested screens are defined in the config | ||
if (payload && config?.screens && Object.keys(config.screens).length) { | ||
payload.pop = true; | ||
} | ||
while (current) { | ||
@@ -56,2 +74,3 @@ if (current.routes.length === 0) { | ||
}; | ||
params.pop = true; | ||
params = params.params; | ||
@@ -64,3 +83,9 @@ } else { | ||
config = config?.screens?.[route.name]; | ||
if (config?.screens && Object.keys(config.screens).length) { | ||
params.pop = true; | ||
} | ||
} | ||
if (payload?.params.screen || payload?.params.state) { | ||
payload.pop = true; | ||
} | ||
if (!payload) { | ||
@@ -67,0 +92,0 @@ return; |
@@ -285,3 +285,4 @@ "use strict"; | ||
params: route.params.params, | ||
path: route.params.path | ||
path: route.params.path, | ||
pop: route.params.pop | ||
}); | ||
@@ -288,0 +289,0 @@ } |
@@ -176,3 +176,7 @@ import type { DefaultRouterOptions, InitialState, NavigationAction, NavigationState, ParamListBase, PartialState, Route } from '@react-navigation/routers'; | ||
* | ||
* @param options Object with `name` for the route to navigate to, and a `params` object. | ||
* @param options.name Name of the route to navigate to. | ||
* @param [options.params] Params object for the route. | ||
* @param [options.path] Path to associate the route with (e.g. for deep links). | ||
* @param [options.merge] Whether to merge the params onto the route. | ||
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route. | ||
*/ | ||
@@ -185,2 +189,3 @@ navigate<RouteName extends keyof ParamList>(options: { | ||
merge?: boolean; | ||
pop?: boolean; | ||
}; | ||
@@ -638,2 +643,3 @@ }[RouteName]): void; | ||
initial?: never; | ||
pop?: never; | ||
path?: string; | ||
@@ -647,2 +653,3 @@ state: PartialState<NavigationState> | NavigationState | undefined; | ||
path?: string; | ||
pop?: boolean; | ||
state?: never; | ||
@@ -654,2 +661,3 @@ } : { | ||
path?: string; | ||
pop?: boolean; | ||
state?: never; | ||
@@ -656,0 +664,0 @@ }; |
@@ -60,2 +60,3 @@ import type { NavigationAction, NavigationState, ParamListBase, PartialState, Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -103,2 +104,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -105,0 +107,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -34,2 +34,3 @@ import { type DefaultRouterOptions, type NavigationAction, type NavigationState, type ParamListBase, type PartialState, type RouterFactory } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -107,2 +108,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -150,2 +152,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -152,0 +155,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -33,2 +33,3 @@ import { type NavigationAction, type NavigationState, type ParamListBase, type Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -35,0 +36,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -38,2 +38,3 @@ import { type NavigationAction, type NavigationState, type ParamListBase, type Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -40,0 +41,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -176,3 +176,7 @@ import type { DefaultRouterOptions, InitialState, NavigationAction, NavigationState, ParamListBase, PartialState, Route } from '@react-navigation/routers'; | ||
* | ||
* @param options Object with `name` for the route to navigate to, and a `params` object. | ||
* @param options.name Name of the route to navigate to. | ||
* @param [options.params] Params object for the route. | ||
* @param [options.path] Path to associate the route with (e.g. for deep links). | ||
* @param [options.merge] Whether to merge the params onto the route. | ||
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route. | ||
*/ | ||
@@ -185,2 +189,3 @@ navigate<RouteName extends keyof ParamList>(options: { | ||
merge?: boolean; | ||
pop?: boolean; | ||
}; | ||
@@ -638,2 +643,3 @@ }[RouteName]): void; | ||
initial?: never; | ||
pop?: never; | ||
path?: string; | ||
@@ -647,2 +653,3 @@ state: PartialState<NavigationState> | NavigationState | undefined; | ||
path?: string; | ||
pop?: boolean; | ||
state?: never; | ||
@@ -654,2 +661,3 @@ } : { | ||
path?: string; | ||
pop?: boolean; | ||
state?: never; | ||
@@ -656,0 +664,0 @@ }; |
@@ -60,2 +60,3 @@ import type { NavigationAction, NavigationState, ParamListBase, PartialState, Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -103,2 +104,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -105,0 +107,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -34,2 +34,3 @@ import { type DefaultRouterOptions, type NavigationAction, type NavigationState, type ParamListBase, type PartialState, type RouterFactory } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -107,2 +108,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -150,2 +152,3 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -152,0 +155,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -33,2 +33,3 @@ import { type NavigationAction, type NavigationState, type ParamListBase, type Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -35,0 +36,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
@@ -38,2 +38,3 @@ import { type NavigationAction, type NavigationState, type ParamListBase, type Router } from '@react-navigation/routers'; | ||
merge?: boolean; | ||
pop?: boolean; | ||
}): void; | ||
@@ -40,0 +41,0 @@ navigateDeprecated<RouteName extends string>(...args: [screen: string] | [screen: string, params: object | undefined]): void; |
{ | ||
"name": "@react-navigation/core", | ||
"description": "Core utilities for building navigators", | ||
"version": "7.3.1", | ||
"version": "7.4.0", | ||
"keywords": [ | ||
@@ -49,3 +49,3 @@ "react", | ||
"dependencies": { | ||
"@react-navigation/routers": "^7.1.2", | ||
"@react-navigation/routers": "^7.2.0", | ||
"escape-string-regexp": "^4.0.0", | ||
@@ -99,3 +99,3 @@ "nanoid": "3.3.8", | ||
}, | ||
"gitHead": "85c53f6593a6894018be936e6a47654634e5e4b4" | ||
"gitHead": "2dc0ec3eaca7aa010d9934cabaa64562b265271a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1247745
0.46%19644
0.61%