Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const {fromKey} = action.payload
const activeKey = getActiveKey(navigation.state)
if (fromKey !== activeKey) {
logger.warn('Skipping append on wrong screen')
return
}
}
if (action.payload.replace) {
return [StackActions.replace({params, routeName})]
}
return [StackActions.push({params, routeName})]
}
case RouteTreeGen.switchTab: {
return [NavigationActions.navigate({routeName: action.payload.tab})]
}
case RouteTreeGen.switchLoggedIn: {
return [NavigationActions.navigate({routeName: action.payload.loggedIn ? 'loggedIn' : 'loggedOut'})]
}
case RouteTreeGen.clearModals: {
const numModals = getNumModals(navigation)
return numModals ? [StackActions.pop({n: numModals})] : []
}
case RouteTreeGen.navigateUp:
return [NavigationActions.back({key: action.payload.fromKey})]
case RouteTreeGen.navUpToScreen: {
const fullPath = Constants._getFullRouteForNavigator(navigation.state)
const popActions: Array = []
const isInStack = fullPath.reverse().some(r => {
if (r.routeName === action.payload.routeName) {
return true
let goBack = (...args) => {
const splitNavigator = getSplitNavigator(navigation)
if (splitNavigator) {
splitNavigator.dispatch(
NavigationActions.navigate({ routeName: shownPaneRouteName })
)
}
if (navigation.goBack(...args) === false) {
navigation.navigate('placeholder')
splitNavigator.dispatch(
NavigationActions.navigate({ routeName: 'placeholder' })
)
}
}
render() {
const {
children,
params,
routeName,
routeKey,
navigation,
action,
} = this.props;
const topNavigation = getTopNavigation(navigation);
const topRouter = topNavigation.router;
const navAction =
action ||
NavigationActions.navigate({
routeName,
key: routeKey,
params,
});
if (!action && !routeName && !routeKey) {
throw new Error(
'Must provide a routeName, routeKey, or a navigation action prop to '
);
}
if (action && routeKey) {
throw new Error(
'Cannot specify a conflicting "routeKey" and a navigation "action" prop. Either use routeName with routeKey to specify a navigate action, or provide the specific navigation "action" prop.'
);
}
if (action && routeName) {
throw new Error(
function navigate(routeName, params?) {
_navigator.dispatch(
NavigationActions.navigate({
routeName,
params,
})
);
}
function replace(routeName, params?) {
_navigator.dispatch(
StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName, params })],
}
))
}