UNPKG

1.43 kBTypeScriptView Raw
1import { NavigationAction, NavigationState, ParamListBase, Router } from '@react-navigation/routers';
2import type { NavigationHelpers, NavigationProp } from './types';
3import type { NavigationEventEmitter } from './useEventEmitter';
4declare type Options<State extends NavigationState, EventMap extends Record<string, any>> = {
5 state: State;
6 getState: () => State;
7 navigation: NavigationHelpers<ParamListBase> & Partial<NavigationProp<ParamListBase, string, any, any, any>>;
8 setOptions: (cb: (options: Record<string, object>) => Record<string, object>) => void;
9 router: Router<State, NavigationAction>;
10 emitter: NavigationEventEmitter<EventMap>;
11};
12declare type NavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>> = Record<string, NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap>>;
13/**
14 * Hook to cache navigation objects for each screen in the navigator.
15 * It's important to cache them to make sure navigation objects don't change between renders.
16 * This lets us apply optimizations like `React.memo` to minimize re-rendering screens.
17 */
18export default function useNavigationCache<State extends NavigationState, ScreenOptions extends {}, EventMap extends Record<string, any>>({ state, getState, navigation, setOptions, router, emitter, }: Options<State, EventMap>): NavigationCache<State, ScreenOptions, EventMap>;
19export {};