How to use @react-navigation/routers - 10 common examples

To help you get started, we’ve selected a few @react-navigation/routers 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 / navigation-ex / packages / stack / src / views / Stack / StackView.tsx View on Github external
private handleGoBack = ({ route }: { route: Route }) => {
    const { state, navigation } = this.props;

    // This event will trigger when a gesture ends
    // We need to perform the transition before removing the route completely
    navigation.dispatch({
      ...StackActions.pop(),
      source: route.key,
      target: state.key,
    });
  };
github react-navigation / navigation-ex / packages / stack / src / navigators / createStackNavigator.tsx View on Github external
requestAnimationFrame(() => {
          if (state.index > 0 && isFocused && !e.defaultPrevented) {
            // When user taps on already focused tab and we're inside the tab,
            // reset the stack to replicate native behaviour
            navigation.dispatch({
              ...StackActions.popToTop(),
              target: state.key,
            });
          }
        });
      }),
github react-navigation / navigation-ex / packages / native-stack / src / navigators / createNativeStackNavigator.tsx View on Github external
requestAnimationFrame(() => {
          if (state.index > 0 && isFocused && !e.defaultPrevented) {
            // When user taps on already focused tab and we're inside the tab,
            // reset the stack to replicate native behaviour
            navigation.dispatch({
              ...StackActions.popToTop(),
              target: state.key,
            });
          }
        });
      }),
github react-navigation / navigation-ex / packages / drawer / src / views / DrawerView.tsx View on Github external
const handleDrawerClose = () => {
    navigation.dispatch({
      ...DrawerActions.closeDrawer(),
      target: state.key,
    });

    navigation.emit({ type: 'drawerClose' });
  };
github react-navigation / navigation-ex / packages / drawer / src / views / DrawerView.tsx View on Github external
const handleDrawerOpen = () => {
    navigation.dispatch({
      ...DrawerActions.openDrawer(),
      target: state.key,
    });

    navigation.emit({ type: 'drawerOpen' });
  };
github react-navigation / navigation-ex / packages / compat / src / StackActions.tsx View on Github external
export function pop({ n = 1 }: { n: number }): StackActionType {
  return StackActions.pop(n);
}
github react-navigation / navigation-ex / packages / stack / src / views / Header / Header.tsx View on Github external
? () =>
              navigation.dispatch({
                ...StackActions.pop(),
                source: scene.route.key,
              })
          : undefined
github react-navigation / navigation-ex / packages / native-stack / src / views / NativeStackView.tsx View on Github external
onDismissed={() => {
              navigation.dispatch({
                ...StackActions.pop(),
                source: route.key,
                target: state.key,
              });
            }}
          >
github react-navigation / navigation-ex / packages / drawer / src / views / DrawerItemList.tsx View on Github external
onPress={() => {
          navigation.dispatch({
            ...(focused
              ? DrawerActions.closeDrawer()
              : CommonActions.navigate(route.name)),
            target: state.key,
          });
        }}
      />
github react-navigation / navigation-ex / packages / drawer / src / views / DrawerSidebar.tsx View on Github external
private handleItemPress = ({
    route,
    focused,
  }: {
    route: Route;
    focused: boolean;
  }) => {
    const { state, navigation } = this.props;

    navigation.dispatch({
      ...(focused
        ? DrawerActions.closeDrawer()
        : CommonActions.navigate(route.name)),
      target: state.key,
    });
  };