How to use the @react-navigation/core.NavigationActions.back 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 react-navigation / native / src / createAppContainer.js View on Github external
this.subs = BackHandler.addEventListener('hardwareBackPress', () => {
          if (!this._isMounted) {
            this.subs && this.subs.remove();
          } else {
            // dispatch returns true if the action results in a state change,
            // and false otherwise. This maps well to what BackHandler expects
            // from a callback -- true if handled, false if not handled
            return this.dispatch(NavigationActions.back());
          }
        });
      }
github keybase / client / shared / router-v2 / router.shared.tsx View on Github external
}

      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<unknown> = []
      const isInStack = fullPath.reverse().some(r => {
        if (r.routeName === action.payload.routeName) {
          return true
        }
        popActions.push(StackActions.pop({}))
        return false
      })
      return isInStack ? popActions : []
    }
    case RouteTreeGen.resetStack: {
      // TODO check for append dupes within these
      const actions = action.payload.actions.reduce(
        (arr, a) => [...arr, ...(oldActionToNewActions(a, navigation, true) || [])],
github kmagiera / react-native-screens / Example / nativeNavigation / createStackNavigator.js View on Github external
_removeScene = scene => {
    const { navigation } = this.props;
    navigation.dispatch(
      NavigationActions.back({
        key: scene.route.key,
        immediate: true,
      })
    );
    navigation.dispatch(StackActions.completeTransition());
  };
github react-navigation / stack / src / views / StackView / StackViewLayout.tsx View on Github external
const onCompleteAnimation = () => {
      this.immediateIndex = null;
      const backFromScene = scenes.find(s => s.index === toValue + 1);
      if (backFromScene) {
        navigation.dispatch(
          NavigationActions.back({
            key: backFromScene.route.key,
            immediate: true,
          })
        );
        navigation.dispatch(StackActions.completeTransition());
      }
    };