How to use the @react-navigation/native.useNavigationBuilder function in @react-navigation/native

To help you get started, we’ve selected a few @react-navigation/native 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 / compat / src / createSwitchNavigator.tsx View on Github external
function SwitchNavigator(props: Props) {
  const { state, descriptors } = useNavigationBuilder<
    TabNavigationState,
    TabRouterOptions,
    {},
    {}
  >(TabRouter, props);

  return descriptors[state.routes[state.index].key].render();
}
github react-navigation / navigation-ex / packages / drawer / src / navigators / createDrawerNavigator.tsx View on Github external
function DrawerNavigator({
  initialRouteName,
  children,
  screenOptions,
  ...rest
}: Props) {
  const { state, descriptors, navigation } = useNavigationBuilder<
    DrawerNavigationState,
    DrawerRouterOptions,
    DrawerNavigationOptions,
    DrawerNavigationEventMap
  >(DrawerRouter, {
    initialRouteName,
    children,
    screenOptions,
  });

  return (
github react-navigation / navigation-ex / packages / stack / src / navigators / createStackNavigator.tsx View on Github external
function StackNavigator({
  initialRouteName,
  children,
  screenOptions,
  ...rest
}: Props) {
  const { state, descriptors, navigation } = useNavigationBuilder<
    StackNavigationState,
    StackRouterOptions,
    StackNavigationOptions,
    StackNavigationEventMap
  >(StackRouter, {
    initialRouteName,
    children,
    screenOptions,
  });

  React.useEffect(
    () =>
      navigation.addListener &&
      navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
        const isFocused = navigation.isFocused();
github react-navigation / navigation-ex / packages / material-bottom-tabs / src / navigators / createMaterialBottomTabNavigator.tsx View on Github external
function MaterialBottomTabNavigator({
  initialRouteName,
  backBehavior,
  children,
  screenOptions,
  ...rest
}: Props) {
  const { state, descriptors, navigation } = useNavigationBuilder<
    TabNavigationState,
    TabRouterOptions,
    MaterialBottomTabNavigationOptions,
    MaterialBottomTabNavigationEventMap
  >(TabRouter, {
    initialRouteName,
    backBehavior,
    children,
    screenOptions,
  });

  return (
github react-navigation / navigation-ex / packages / bottom-tabs / src / navigators / createBottomTabNavigator.tsx View on Github external
function BottomTabNavigator({
  initialRouteName,
  backBehavior,
  children,
  screenOptions,
  ...rest
}: Props) {
  const { state, descriptors, navigation } = useNavigationBuilder<
    TabNavigationState,
    TabRouterOptions,
    BottomTabNavigationOptions,
    BottomTabNavigationEventMap
  >(TabRouter, {
    initialRouteName,
    backBehavior,
    children,
    screenOptions,
  });

  return (
github react-navigation / navigation-ex / packages / material-top-tabs / src / navigators / createMaterialTopTabNavigator.tsx View on Github external
function MaterialTopTabNavigator({
  initialRouteName,
  backBehavior,
  children,
  screenOptions,
  ...rest
}: Props) {
  const { state, descriptors, navigation } = useNavigationBuilder<
    TabNavigationState,
    TabRouterOptions,
    MaterialTopTabNavigationOptions,
    MaterialTopTabNavigationEventMap
  >(TabRouter, {
    initialRouteName,
    backBehavior,
    children,
    screenOptions,
  });

  return (
github callstack / react-native-paper / example / src / SimpleNavigator.tsx View on Github external
function SimpleNavigator(
  props: DefaultNavigatorOptions
) {
  const { state, descriptors } = useNavigationBuilder(StackRouter, props);
  const route = state.routes[state.index];
  const { render, options, navigation } = descriptors[route.key];

  return (
    <>
      {options.headerShown !== false &&
        options.header &&
        options.header({
          navigation,
          scene: { descriptor: descriptors[route.key] },
          previous:
            state.index === 0
              ? undefined
              : { descriptor: descriptors[state.routes[state.index - 1].key] },
        })}
      {render()}
github react-navigation / navigation-ex / packages / native-stack / src / navigators / createNativeStackNavigator.tsx View on Github external
function NativeStackNavigator(props: NativeStackNavigatorProps) {
  if (!screensEnabled()) {
    throw new Error(
      'Native stack is only available if React Native Screens is enabled.'
    );
  }

  const { initialRouteName, children, screenOptions, ...rest } = props;
  const { state, descriptors, navigation } = useNavigationBuilder<
    StackNavigationState,
    StackRouterOptions,
    NativeStackNavigationOptions,
    {}
  >(StackRouter, {
    initialRouteName,
    children,
    screenOptions,
  });

  React.useEffect(
    () =>
      navigation.addListener &&
      navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
        const isFocused = navigation.isFocused();