Type alias NavigationHelpersCommon<ParamList, State>

NavigationHelpersCommon<ParamList, State>: {
    canGoBack(): boolean;
    dispatch(action): void;
    getId(): undefined | string;
    getParent<T>(id?): T;
    getState(): State;
    goBack(): void;
    isFocused(): boolean;
    navigate<RouteName>(...args): void;
    navigate<RouteName>(options): void;
    reset(state): void;
} & PrivateValueStore<[ParamList, unknown, unknown]>

Type Parameters

Type declaration

  • canGoBack:function
    • Check if dispatching back action will be handled by navigation. Note that this method doesn't re-render screen when the result changes. So don't use it in render.

      Returns boolean

  • dispatch:function
    • Dispatch an action or an update function to the router. The update function will receive the current state,

      Parameters

      • action: Readonly<{
            payload?: object;
            source?: string;
            target?: string;
            type: string;
        }> | ((state) => Readonly<{
            payload?: object;
            source?: string;
            target?: string;
            type: string;
        }>)

        Action object or update function.

      Returns void

  • getId:function
    • Returns the name of the navigator specified in the name prop. If no name is specified, returns undefined.

      Returns undefined | string

  • getParent:function
    • Returns the navigation helpers from a parent navigator based on the ID. If an ID is provided, the navigation helper from the parent navigator with matching ID (including current) will be returned. If no ID is provided, the navigation helper from the immediate parent navigator will be returned.

      Type Parameters

      Parameters

      • Optional id: string

        Optional ID of a parent navigator.

      Returns T

  • getState:function
    • Returns the navigator's state. Note that this method doesn't re-render screen when the result changes. So don't use it in render.

      Returns State

  • goBack:function
    • Go back to the previous route in history.

      Returns void

  • isFocused:function
    • Check if the screen is focused. The method returns true if focused, false otherwise. Note that this method doesn't re-render screen when the focus changes. So don't use it in render. To get notified of focus changes, use addListener('focus', cb) and addListener('blur', cb). To conditionally render content based on focus state, use the useIsFocused hook.

      Returns boolean

  • navigate:function
    • Navigate to a route in current navigation tree.

      Type Parameters

      • RouteName extends string | number | symbol

      Parameters

      Returns void

    • Navigate to a route in current navigation tree.

      Type Parameters

      • RouteName extends string | number | symbol

      Parameters

      • options: RouteName extends unknown
            ? {
                key: string;
                merge?: boolean;
                params?: ParamList[RouteName];
            } | {
                key?: string;
                merge?: boolean;
                name: RouteName;
                params: ParamList[RouteName];
            }
            : never

      Returns void

  • reset:function
    • Reset the navigation state to the provided state.

      Parameters

      Returns void