@react-navigation/core

  • Version 6.0.1
  • Published
  • 1.06 MB
  • 5 dependencies
  • MIT license

Install

npm i @react-navigation/core
yarn add @react-navigation/core
pnpm add @react-navigation/core

Overview

Core utilities for building navigators

Index

Variables

variable BaseNavigationContainer

const BaseNavigationContainer: any;
  • Container component which holds the navigation state. This should be rendered at the root wrapping the whole app.

    Parameter

    props.initialState Initial state object for the navigation tree.

    Parameter

    props.onStateChange Callback which is called with the latest navigation state when it changes.

    Parameter

    props.children Child elements to render the content.

    Parameter

    props.ref Ref object which refers to the navigation object containing helper methods.

variable CurrentRenderContext

const CurrentRenderContext: any;
  • Context which holds the values for the current navigation tree. Intended for use in SSR. This is not safe to use on the client.

const NavigationContainerRefContext: any;
  • Context which holds the route prop for a screen.

const NavigationContext: any;
  • Context which holds the navigation prop for a screen.

const NavigationHelpersContext: any;
  • Context which holds the navigation helpers of the parent navigator. Navigators should use this context in their view component.

const NavigationRouteContext: any;
  • Context which holds the route prop for a screen.

Functions

function createNavigationContainerRef

createNavigationContainerRef: <
ParamList extends {} = ReactNavigation.RootParamList
>() => NavigationContainerRefWithCurrent<ParamList>;

    function createNavigatorFactory

    createNavigatorFactory: <
    State extends any,
    ScreenOptions extends {},
    EventMap extends EventMapBase,
    NavigatorComponent extends any
    >(
    Navigator: NavigatorComponent
    ) => <ParamList extends any>() => TypedNavigator<
    ParamList,
    State,
    ScreenOptions,
    EventMap,
    NavigatorComponent
    >;
    • Higher order component to create a Navigator and Screen pair. Custom navigators should wrap the navigator component in createNavigator before exporting.

      Parameter Navigator

      The navigtor component to wrap.

      Returns

      Factory method to create a Navigator and Screen pair.

    function findFocusedRoute

    findFocusedRoute: (
    state: any
    ) =>
    | (Omit<
    import('@react-navigation/routers').Route<string, object | undefined>,
    'key'
    > & {
    state?:
    | Readonly<
    Partial<
    Omit<
    Readonly<{
    key: string;
    index: number;
    routeNames: string[];
    history?: unknown[] | undefined;
    routes: (Readonly<{
    key: string;
    name: string;
    path?: string | undefined;
    }> &
    Readonly<{
    params?: Readonly<object | undefined>;
    }> & {
    state?:
    | Readonly<any>
    | import('@react-navigation/routers').PartialState<
    Readonly<any>
    >
    | undefined;
    })[];
    type: string;
    stale: false;
    }>,
    'stale' | 'routes'
    >
    > & {
    routes: (Omit<
    import('@react-navigation/routers').Route<
    string,
    object | undefined
    >,
    'key'
    > &
    any)[];
    }
    >
    | undefined;
    })
    | undefined;

      function getActionFromState

      getActionFromState: (
      state: any,
      options?: Options
      ) => NavigateAction<NavigationState> | CommonActions.Action | undefined;

        function getFocusedRouteNameFromRoute

        getFocusedRouteNameFromRoute: (route: any) => string | undefined;

          function getPathFromState

          getPathFromState: <ParamList extends {}>(
          state: State,
          options?: Options<ParamList>
          ) => string;
          • Utility to serialize a navigation state object to a path string.

            Parameter state

            Navigation state to serialize.

            Parameter options

            Extra options to fine-tune how to serialize the path.

            Returns

            Path representing the state, e.g. /foo/bar?count=42.

            Example 1

            getPathFromState(
            {
            routes: [
            {
            name: 'Chat',
            params: { author: 'Jane', id: 42 },
            },
            ],
            },
            {
            screens: {
            Chat: {
            path: 'chat/:author/:id',
            stringify: { author: author => author.toLowerCase() }
            }
            }
            }
            )

          function getStateFromPath

          getStateFromPath: <ParamList extends {}>(
          path: string,
          options?: Options<ParamList>
          ) => ResultState | undefined;
          • Utility to parse a path string to initial state object accepted by the container. This is useful for deep linking when we need to handle the incoming URL.

            Parameter path

            Path string to parse and convert, e.g. /foo/bar?count=42.

            Parameter options

            Extra options to fine-tune how to parse the path.

            Example 1

            getStateFromPath(
            '/chat/jane/42',
            {
            screens: {
            Chat: {
            path: 'chat/:author/:id',
            parse: { id: Number }
            }
            }
            }
            )

          function useFocusEffect

          useFocusEffect: (effect: EffectCallback) => void;
          • Hook to run an effect in a focused screen, similar to React.useEffect. This can be used to perform side-effects such as fetching data or subscribing to events. The passed callback should be wrapped in React.useCallback to avoid running the effect too often.

            Parameter callback

            Memoized callback containing the effect, should optionally return a cleanup function.

          function useIsFocused

          useIsFocused: () => boolean;
          • Hook to get the current focus state of the screen. Returns a true if screen is focused, otherwise false. This can be used if a component needs to render something based on the focus state.

          function useNavigation

          useNavigation: <
          T = NavigationProp<ReactNavigation.RootParamList, never, any, {}, {}>
          >() => T;
          • Hook to access the navigation prop of the parent screen anywhere.

            Returns

            Navigation prop of the parent screen.

          function useNavigationBuilder

          useNavigationBuilder: <
          State extends any,
          RouterOptions extends any,
          ActionHelpers extends Record<string, () => void>,
          ScreenOptions extends {},
          EventMap extends Record<string, any>
          >(
          createRouter: any,
          options: DefaultNavigatorOptions<ParamListBase, State, ScreenOptions, EventMap> &
          RouterOptions
          ) => {
          state: State;
          navigation: {
          dispatch(
          action:
          | Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>
          | ((
          state: Readonly<{
          key: string;
          index: number;
          routeNames: string[];
          history?: unknown[] | undefined;
          routes: (Readonly<{
          key: string;
          name: string;
          path?: string | undefined;
          }> &
          Readonly<{ params?: Readonly<object | undefined> }> & {
          state?:
          | Readonly<any>
          | PartialState<Readonly<any>>
          | undefined;
          })[];
          type: string;
          stale: false;
          }>
          ) => Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>)
          ): void;
          navigate<RouteName extends string>(
          ...args: [screen: RouteName] | [screen: RouteName, params: object]
          ): void;
          navigate<RouteName_1 extends string>(
          options:
          | {
          key: string;
          params?: object | undefined;
          merge?: boolean | undefined;
          }
          | {
          name: RouteName_1;
          key?: string | undefined;
          params: object | undefined;
          merge?: boolean | undefined;
          }
          ): void;
          reset(state: any): void;
          goBack(): void;
          isFocused(): boolean;
          canGoBack(): boolean;
          getParent<
          T = NavigationProp<
          any,
          string,
          Readonly<{
          key: string;
          index: number;
          routeNames: string[];
          history?: unknown[] | undefined;
          routes: (Readonly<{
          key: string;
          name: string;
          path?: string | undefined;
          }> &
          Readonly<{ params?: Readonly<object | undefined> }> & {
          state?:
          | Readonly<any>
          | PartialState<Readonly<any>>
          | undefined;
          })[];
          type: string;
          stale: false;
          }>,
          {},
          {}
          >
          >(): T;
          getState(): Readonly<{
          key: string;
          index: number;
          routeNames: string[];
          history?: unknown[] | undefined;
          routes: (Readonly<{
          key: string;
          name: string;
          path?: string | undefined;
          }> &
          Readonly<{ params?: Readonly<object | undefined> }> & {
          state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
          })[];
          type: string;
          stale: false;
          }>;
          } & PrivateValueStore<any, string, {}> &
          EventEmitter<EventMap> & {
          setParams<RouteName_2 extends string>(
          params: Partial<object | undefined>
          ): void;
          } & {
          dispatch(
          action:
          | Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>
          | ((
          state: any
          ) => Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>)
          ): void;
          navigate<RouteName extends string>(
          ...args: [screen: RouteName] | [screen: RouteName, params: object]
          ): void;
          navigate<RouteName_1 extends string>(
          options:
          | {
          key: string;
          params?: object | undefined;
          merge?: boolean | undefined;
          }
          | {
          name: RouteName_1;
          key?: string | undefined;
          params: object | undefined;
          merge?: boolean | undefined;
          }
          ): void;
          reset(state: any): void;
          goBack(): void;
          isFocused(): boolean;
          canGoBack(): boolean;
          getParent<
          T = NavigationProp<
          any,
          string,
          Readonly<{
          key: string;
          index: number;
          routeNames: string[];
          history?: unknown[] | undefined;
          routes: (Readonly<{
          key: string;
          name: string;
          path?: string | undefined;
          }> &
          Readonly<{ params?: Readonly<object | undefined> }> & {
          state?:
          | Readonly<any>
          | PartialState<Readonly<any>>
          | undefined;
          })[];
          type: string;
          stale: false;
          }>,
          {},
          {}
          >
          >(): T;
          getState(): any;
          } & {
          setParams(params: Partial<object | undefined>): void;
          setOptions(options: Partial<any>): void;
          } & EventConsumer<any> &
          PrivateValueStore<any, string, any> &
          ActionHelpers;
          descriptors: Record<
          string,
          Descriptor<
          ScreenOptions,
          {
          dispatch(
          action:
          | Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>
          | ((
          state: State
          ) => Readonly<{
          type: string;
          payload?: object | undefined;
          source?: string | undefined;
          target?: string | undefined;
          }>)
          ): void;
          navigate<RouteName extends string>(
          ...args:
          | [screen: RouteName]
          | [screen: RouteName, params: object]
          ): void;
          navigate<RouteName_1 extends string>(
          options:
          | {
          key: string;
          params?: object | undefined;
          merge?: boolean | undefined;
          }
          | {
          name: RouteName_1;
          key?: string | undefined;
          params: object | undefined;
          merge?: boolean | undefined;
          }
          ): void;
          reset(state: State | PartialState<State>): void;
          goBack(): void;
          isFocused(): boolean;
          canGoBack(): boolean;
          getParent<
          T = NavigationProp<
          any,
          string,
          Readonly<{
          key: string;
          index: number;
          routeNames: string[];
          history?: unknown[] | undefined;
          routes: (Readonly<{
          key: string;
          name: string;
          path?: string | undefined;
          }> &
          Readonly<{
          params?: Readonly<object | undefined>;
          }> & {
          state?:
          | Readonly<any>
          | PartialState<Readonly<any>>
          | undefined;
          })[];
          type: string;
          stale: false;
          }>,
          {},
          {}
          >
          >(): T;
          getState(): State;
          } & PrivateValueStore<any, string, {}> & {
          setParams(params: Partial<object | undefined>): void;
          setOptions(options: Partial<ScreenOptions>): void;
          } & EventConsumer<EventMap & EventMapCore<State>> &
          PrivateValueStore<any, string, EventMap> &
          ActionHelpers,
          any
          >
          >;
          NavigationContent: (
          rest: Omit<
          React.ProviderProps<
          import('./types').NavigationHelpers<ParamListBase, {}> | undefined
          >,
          'value'
          >
          ) => any;
          };
          • Hook for building navigators.

            Parameter createRouter

            Factory method which returns router object.

            Parameter options

            Options object containing children and additional options for the router.

            Returns

            An object containing state, navigation, descriptors objects.

          function useNavigationContainerRef

          useNavigationContainerRef: <
          ParamList extends {} = ReactNavigation.RootParamList
          >() => NavigationContainerRefWithCurrent<ParamList>;

            function useNavigationState

            useNavigationState: <ParamList extends any, T>(
            selector: Selector<ParamList, T>
            ) => T;
            • Hook to get a value from the current navigation state using a selector.

              Parameter selector

              Selector function to get a value from the state.

            function useRoute

            useRoute: <T extends any>() => T;
            • Hook to access the route prop of the parent screen anywhere.

              Returns

              Route prop of the parent screen.

            function validatePathConfig

            validatePathConfig: (config: any, root?: boolean) => void;

              Classes

              class PrivateValueStore

              class PrivateValueStore<A, B, C> {}

                property ''

                protected ''?: { a: A; b: B; c: C };
                • UGLY HACK! DO NOT USE THE TYPE!!!

                  TypeScript requires a type to be used to be able to infer it. The type should exist as its own without any operations such as union. So we need to figure out a way to store this type in a property. The problem with a normal property is that it shows up in intelliSense. Adding private keyword works, but the annotation is stripped away in declaration. Turns out if we use an empty string, it doesn't show up in intelliSense.

                Type Aliases

                type CompositeNavigationProp

                type CompositeNavigationProp<
                A extends NavigationProp<ParamListBase, string, any, any>,
                B extends NavigationHelpersCommon<ParamListBase, any>
                > = Omit<A & B, keyof NavigationProp<any>> &
                NavigationProp<
                /**
                * Param list from both navigation objects needs to be combined
                * For example, we should be able to navigate to screens in both A and B
                */
                (A extends NavigationHelpersCommon<infer T> ? T : never) &
                (B extends NavigationHelpersCommon<infer U> ? U : never),
                /**
                * The route name should refer to the route name specified in the first type
                * Ideally it should work for any of them, but it's not possible to infer that way
                */
                A extends NavigationProp<any, infer R> ? R : string,
                /**
                * The type of state should refer to the state specified in the first type
                */
                A extends NavigationProp<any, any, infer S> ? S : NavigationState,
                /**
                * Screen options from both navigation objects needs to be combined
                * This allows typechecking `setOptions`
                */
                (A extends NavigationProp<any, any, any, infer O> ? O : {}) &
                (B extends NavigationProp<any, any, any, infer P> ? P : {}),
                /**
                * Event consumer config should refer to the config specified in the first type
                * This allows typechecking `addListener`/`removeListener`
                */
                A extends NavigationProp<any, any, any, any, infer E> ? E : {}
                >;

                  type CompositeScreenProps

                  type CompositeScreenProps<
                  A extends {
                  navigation: NavigationProp<ParamListBase, string, any, any>;
                  route: RouteProp<ParamListBase>;
                  },
                  B extends {
                  navigation: NavigationHelpersCommon<ParamListBase, any>;
                  }
                  > = {
                  navigation: CompositeNavigationProp<A['navigation'], B['navigation']>;
                  route: A['route'];
                  };

                    type DefaultNavigatorOptions

                    type DefaultNavigatorOptions<
                    ParamList extends ParamListBase,
                    State extends NavigationState,
                    ScreenOptions extends {},
                    EventMap extends EventMapBase
                    > = DefaultRouterOptions<Keyof<ParamList>> & {
                    /**
                    * Children React Elements to extract the route configuration from.
                    * Only `Screen`, `Group` and `React.Fragment` are supported as children.
                    */
                    children: React.ReactNode;
                    /**
                    * Event listeners for all the screens in the navigator.
                    */
                    screenListeners?:
                    | ScreenListeners<State, EventMap>
                    | ((props: {
                    route: RouteProp<ParamList>;
                    navigation: any;
                    }) => ScreenListeners<State, EventMap>);
                    /**
                    * Default options for all screens under this navigator.
                    */
                    screenOptions?:
                    | ScreenOptions
                    | ((props: {
                    route: RouteProp<ParamList>;
                    navigation: any;
                    }) => ScreenOptions);
                    /**
                    * Default options specified by the navigator.
                    * It receives the custom options in the arguments if a function is specified.
                    */
                    defaultScreenOptions?:
                    | ScreenOptions
                    | ((props: {
                    route: RouteProp<ParamList>;
                    navigation: any;
                    options: ScreenOptions;
                    }) => ScreenOptions);
                    };

                      type Descriptor

                      type Descriptor<
                      ScreenOptions extends {},
                      Navigation extends NavigationProp<any, any, any, any, any>,
                      Route extends RouteProp<any, any>
                      > = {
                      /**
                      * Render the component associated with this route.
                      */
                      render(): JSX.Element;
                      /**
                      * Options for the route.
                      */
                      options: ScreenOptions;
                      /**
                      * Route object for the screen
                      */
                      route: Route;
                      /**
                      * Navigation object for the screen
                      */
                      navigation: Navigation;
                      };

                        type EventArg

                        type EventArg<
                        EventName extends string,
                        CanPreventDefault extends boolean | undefined = false,
                        Data = undefined
                        > = {
                        /**
                        * Type of the event (e.g. `focus`, `blur`)
                        */
                        readonly type: EventName;
                        readonly target?: string;
                        } & (CanPreventDefault extends true
                        ? {
                        /**
                        * Whether `event.preventDefault()` was called on this event object.
                        */
                        readonly defaultPrevented: boolean;
                        /**
                        * Prevent the default action which happens on this event.
                        */
                        preventDefault(): void;
                        }
                        : {}) &
                        (undefined extends Data
                        ? {
                        readonly data?: Readonly<Data>;
                        }
                        : {
                        readonly data: Readonly<Data>;
                        });

                          type EventConsumer

                          type EventConsumer<EventMap extends EventMapBase> = {
                          /**
                          * Subscribe to events from the parent navigator.
                          *
                          * @param type Type of the event (e.g. `focus`, `blur`)
                          * @param callback Callback listener which is executed upon receiving the event.
                          */
                          addListener<EventName extends Keyof<EventMap>>(
                          type: EventName,
                          callback: EventListenerCallback<EventMap, EventName>
                          ): () => void;
                          removeListener<EventName extends Keyof<EventMap>>(
                          type: EventName,
                          callback: EventListenerCallback<EventMap, EventName>
                          ): void;
                          };

                            type EventEmitter

                            type EventEmitter<EventMap extends EventMapBase> = {
                            /**
                            * Emit an event to child screens.
                            *
                            * @param options.type Type of the event (e.g. `focus`, `blur`)
                            * @param [options.data] Optional information regarding the event.
                            * @param [options.target] Key of the target route which should receive the event.
                            * If not specified, all routes receive the event.
                            */
                            emit<EventName extends Keyof<EventMap>>(
                            options: {
                            type: EventName;
                            target?: string;
                            } & (EventMap[EventName]['canPreventDefault'] extends true
                            ? {
                            canPreventDefault: true;
                            }
                            : {}) &
                            (undefined extends EventMap[EventName]['data']
                            ? {
                            data?: EventMap[EventName]['data'];
                            }
                            : {
                            data: EventMap[EventName]['data'];
                            })
                            ): EventArg<
                            EventName,
                            EventMap[EventName]['canPreventDefault'],
                            EventMap[EventName]['data']
                            >;
                            };

                              type EventListenerCallback

                              type EventListenerCallback<
                              EventMap extends EventMapBase,
                              EventName extends keyof EventMap
                              > = (
                              e: EventArg<
                              Extract<EventName, string>,
                              EventMap[EventName]['canPreventDefault'],
                              EventMap[EventName]['data']
                              >
                              ) => void;

                                type EventMapBase

                                type EventMapBase = Record<
                                string,
                                {
                                data?: any;
                                canPreventDefault?: boolean;
                                }
                                >;

                                  type EventMapCore

                                  type EventMapCore<State extends NavigationState> = {
                                  focus: {
                                  data: undefined;
                                  };
                                  blur: {
                                  data: undefined;
                                  };
                                  state: {
                                  data: {
                                  state: State;
                                  };
                                  };
                                  beforeRemove: {
                                  data: {
                                  action: NavigationAction;
                                  };
                                  canPreventDefault: true;
                                  };
                                  };
                                    type NavigationContainerEventMap = {
                                    /**
                                    * Event which fires when the navigation state changes.
                                    */
                                    state: {
                                    data: {
                                    /**
                                    * The updated state object after the state change.
                                    */
                                    state: NavigationState | PartialState<NavigationState> | undefined;
                                    };
                                    };
                                    /**
                                    * Event which fires when current options changes.
                                    */
                                    options: {
                                    data: {
                                    options: object;
                                    };
                                    };
                                    /**
                                    * Event which fires when an action is dispatched.
                                    * Only intended for debugging purposes, don't use it for app logic.
                                    * This event will be emitted before state changes have been applied.
                                    */
                                    __unsafe_action__: {
                                    data: {
                                    /**
                                    * The action object which was dispatched.
                                    */
                                    action: NavigationAction;
                                    /**
                                    * Whether the action was a no-op, i.e. resulted any state changes.
                                    */
                                    noop: boolean;
                                    /**
                                    * Stack trace of the action, this will only be available during development.
                                    */
                                    stack: string | undefined;
                                    };
                                    };
                                    };
                                      type NavigationContainerProps = {
                                      /**
                                      * Initial navigation state for the child navigators.
                                      */
                                      initialState?: InitialState;
                                      /**
                                      * Callback which is called with the latest navigation state when it changes.
                                      */
                                      onStateChange?: (state: NavigationState | undefined) => void;
                                      /**
                                      * Callback which is called when an action is not handled.
                                      */
                                      onUnhandledAction?: (action: NavigationAction) => void;
                                      /**
                                      * Whether this navigation container should be independent of parent containers.
                                      * If this is not set to `true`, this container cannot be nested inside another container.
                                      * Setting it to `true` disconnects any children navigators from parent container.
                                      */
                                      independent?: boolean;
                                      /**
                                      * Children elements to render.
                                      */
                                      children: React.ReactNode;
                                      };
                                        type NavigationContainerRef<ParamList extends {}> = NavigationHelpers<ParamList> &
                                        EventConsumer<NavigationContainerEventMap> & {
                                        /**
                                        * Reset the navigation state of the root navigator to the provided state.
                                        *
                                        * @param state Navigation state object.
                                        */
                                        resetRoot(state?: PartialState<NavigationState> | NavigationState): void;
                                        /**
                                        * Get the rehydrated navigation state of the navigation tree.
                                        */
                                        getRootState(): NavigationState;
                                        /**
                                        * Get the currently focused navigation route.
                                        */
                                        getCurrentRoute(): Route<string> | undefined;
                                        /**
                                        * Get the currently focused route's options.
                                        */
                                        getCurrentOptions(): object | undefined;
                                        /**
                                        * Whether the navigation container is ready to handle actions.
                                        */
                                        isReady(): boolean;
                                        };
                                          type NavigationContainerRefWithCurrent<
                                          ParamList extends {}
                                          > = NavigationContainerRef<ParamList> & {
                                          current: NavigationContainerRef<ParamList> | null;
                                          };
                                            type NavigationHelpers<
                                            ParamList extends ParamListBase,
                                            EventMap extends EventMapBase = {}
                                            > = NavigationHelpersCommon<ParamList> &
                                            EventEmitter<EventMap> & {
                                            /**
                                            * Update the param object for the route.
                                            * The new params will be shallow merged with the old one.
                                            *
                                            * @param params Params object for the current route.
                                            */
                                            setParams<RouteName extends keyof ParamList>(
                                            params: Partial<ParamList[RouteName]>
                                            ): void;
                                            };
                                              type NavigationProp<
                                              ParamList extends {},
                                              RouteName extends keyof ParamList = Keyof<ParamList>,
                                              State extends NavigationState = NavigationState<ParamList>,
                                              ScreenOptions extends {} = {},
                                              EventMap extends EventMapBase = {}
                                              > = NavigationHelpersCommon<ParamList, State> & {
                                              /**
                                              * Update the param object for the route.
                                              * The new params will be shallow merged with the old one.
                                              *
                                              * @param params Params object for the current route.
                                              */
                                              setParams(params: Partial<ParamList[RouteName]>): void;
                                              /**
                                              * Update the options for the route.
                                              * The options object will be shallow merged with default options object.
                                              *
                                              * @param options Options object for the route.
                                              */
                                              setOptions(options: Partial<ScreenOptions>): void;
                                              } & EventConsumer<EventMap & EventMapCore<State>> &
                                              PrivateValueStore<ParamList, RouteName, EventMap>;
                                                type NavigatorScreenParams<
                                                ParamList,
                                                State extends NavigationState = NavigationState
                                                > =
                                                | {
                                                screen?: never;
                                                params?: never;
                                                initial?: never;
                                                path?: string;
                                                state: PartialState<State> | State | undefined;
                                                }
                                                | {
                                                [RouteName in keyof ParamList]: undefined extends ParamList[RouteName]
                                                ? {
                                                screen: RouteName;
                                                params?: ParamList[RouteName];
                                                initial?: boolean;
                                                path?: string;
                                                state?: never;
                                                }
                                                : {
                                                screen: RouteName;
                                                params: ParamList[RouteName];
                                                initial?: boolean;
                                                path?: string;
                                                state?: never;
                                                };
                                                }[keyof ParamList];

                                                  type PathConfig

                                                  type PathConfig<ParamList extends {}> = {
                                                  path?: string;
                                                  exact?: boolean;
                                                  parse?: Record<string, (value: string) => any>;
                                                  stringify?: Record<string, (value: any) => string>;
                                                  screens?: PathConfigMap<ParamList>;
                                                  initialRouteName?: keyof ParamList;
                                                  };

                                                    type PathConfigMap

                                                    type PathConfigMap<ParamList extends {}> = {
                                                    [RouteName in keyof ParamList]?: NonNullable<
                                                    ParamList[RouteName]
                                                    > extends NavigatorScreenParams<infer T, any>
                                                    ? string | PathConfig<T>
                                                    : string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;
                                                    };

                                                      type RouteConfig

                                                      type RouteConfig<
                                                      ParamList extends ParamListBase,
                                                      RouteName extends keyof ParamList,
                                                      State extends NavigationState,
                                                      ScreenOptions extends {},
                                                      EventMap extends EventMapBase
                                                      > = {
                                                      /**
                                                      * Route name of this screen.
                                                      */
                                                      name: RouteName;
                                                      /**
                                                      * Navigator options for this screen.
                                                      */
                                                      options?:
                                                      | ScreenOptions
                                                      | ((props: {
                                                      route: RouteProp<ParamList, RouteName>;
                                                      navigation: any;
                                                      }) => ScreenOptions);
                                                      /**
                                                      * Event listeners for this screen.
                                                      */
                                                      listeners?:
                                                      | ScreenListeners<State, EventMap>
                                                      | ((props: {
                                                      route: RouteProp<ParamList, RouteName>;
                                                      navigation: any;
                                                      }) => ScreenListeners<State, EventMap>);
                                                      /**
                                                      * Function to return an unique ID for this screen.
                                                      * Receives an object with the route params.
                                                      * For a given screen name, there will always be only one screen corresponding to an ID.
                                                      * If `undefined` is returned, it acts same as no `getId` being specified.
                                                      */
                                                      getId?: ({ params }: { params: ParamList[RouteName] }) => string | undefined;
                                                      /**
                                                      * Initial params object for the route.
                                                      */
                                                      initialParams?: Partial<ParamList[RouteName]>;
                                                      } & RouteConfigComponent<ParamList, RouteName>;

                                                        type RouteConfigComponent

                                                        type RouteConfigComponent<
                                                        ParamList extends ParamListBase,
                                                        RouteName extends keyof ParamList
                                                        > =
                                                        | {
                                                        /**
                                                        * React component to render for this screen.
                                                        */
                                                        component: React.ComponentType<any>;
                                                        getComponent?: never;
                                                        children?: never;
                                                        }
                                                        | {
                                                        /**
                                                        * Lazily get a React component to render for this screen.
                                                        */
                                                        getComponent: () => React.ComponentType<any>;
                                                        component?: never;
                                                        children?: never;
                                                        }
                                                        | {
                                                        /**
                                                        * Render callback to render content of this screen.
                                                        */
                                                        children: (props: {
                                                        route: RouteProp<ParamList, RouteName>;
                                                        navigation: any;
                                                        }) => React.ReactNode;
                                                        component?: never;
                                                        getComponent?: never;
                                                        };

                                                          type RouteGroupConfig

                                                          type RouteGroupConfig<ParamList extends ParamListBase, ScreenOptions extends {}> = {
                                                          /**
                                                          * Navigator options for this screen.
                                                          */
                                                          screenOptions?:
                                                          | ScreenOptions
                                                          | ((props: {
                                                          route: RouteProp<ParamList, keyof ParamList>;
                                                          navigation: any;
                                                          }) => ScreenOptions);
                                                          /**
                                                          * Children React Elements to extract the route configuration from.
                                                          * Only `Screen`, `Group` and `React.Fragment` are supported as children.
                                                          */
                                                          children: React.ReactNode;
                                                          };

                                                            type RouteProp

                                                            type RouteProp<
                                                            ParamList extends ParamListBase,
                                                            RouteName extends keyof ParamList = Keyof<ParamList>
                                                            > = Route<Extract<RouteName, string>, ParamList[RouteName]>;

                                                              type ScreenListeners

                                                              type ScreenListeners<
                                                              State extends NavigationState,
                                                              EventMap extends EventMapBase
                                                              > = Partial<
                                                              {
                                                              [EventName in keyof (EventMap & EventMapCore<State>)]: EventListenerCallback<
                                                              EventMap,
                                                              EventName
                                                              >;
                                                              }
                                                              >;

                                                                type TypedNavigator

                                                                type TypedNavigator<
                                                                ParamList extends ParamListBase,
                                                                State extends NavigationState,
                                                                ScreenOptions extends {},
                                                                EventMap extends EventMapBase,
                                                                Navigator extends React.ComponentType<any>
                                                                > = {
                                                                /**
                                                                * Navigator component which manages the child screens.
                                                                */
                                                                Navigator: React.ComponentType<
                                                                Omit<
                                                                React.ComponentProps<Navigator>,
                                                                keyof DefaultNavigatorOptions<any, any, any, any>
                                                                > &
                                                                DefaultNavigatorOptions<ParamList, State, ScreenOptions, EventMap>
                                                                >;
                                                                /**
                                                                * Component used for grouping multiple route configuration.
                                                                */
                                                                Group: React.ComponentType<RouteGroupConfig<ParamList, ScreenOptions>>;
                                                                /**
                                                                * Component used for specifying route configuration.
                                                                */
                                                                Screen: <RouteName extends keyof ParamList>(
                                                                _: RouteConfig<ParamList, RouteName, State, ScreenOptions, EventMap>
                                                                ) => null;
                                                                };

                                                                  Package Files (23)

                                                                  Dependencies (5)

                                                                  Dev Dependencies (9)

                                                                  Peer Dependencies (1)

                                                                  Badge

                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@react-navigation/core.

                                                                  • Markdown
                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@react-navigation/core)
                                                                  • HTML
                                                                    <a href="https://www.jsdocs.io/package/@react-navigation/core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>