How to use the @react-navigation/core.NavigationActions.navigate function in @react-navigation/core

To help you get started, we’ve selected a few @react-navigation/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keybase / client / shared / router-v2 / router.shared.tsx View on Github external
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
github berty / berty / client / react-native / app / view / component / BackActionProvider.js View on Github external
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' })
      )
    }
  }
github react-navigation / web / src / Link.js View on Github external
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(
github henninghall / react-native-web-typescript-navigation-starter / src / navigation / NavigationService.ts View on Github external
function navigate(routeName, params?) {
  _navigator.dispatch(
    NavigationActions.navigate({
      routeName,
      params,
    })
  );
}
github henninghall / react-native-web-typescript-navigation-starter / src / navigation / NavigationService.ts View on Github external
function replace(routeName, params?) {
  _navigator.dispatch(
    StackActions.reset({
      index: 0,
      actions: [NavigationActions.navigate({ routeName, params })],
    }
    ))
}