UNPKG

1.77 kBTypeScriptView Raw
1import type { NavigationAction, NavigationState, ParamListBase } from '@react-navigation/routers';
2import * as React from 'react';
3import type { NavigationHelpers } from './types';
4export type ListenerMap = {
5 action: ChildActionListener;
6 focus: FocusedNavigationListener;
7};
8export type KeyedListenerMap = {
9 getState: GetStateListener;
10 beforeRemove: ChildBeforeRemoveListener;
11};
12export type AddListener = <T extends keyof ListenerMap>(type: T, listener: ListenerMap[T]) => void;
13export type AddKeyedListener = <T extends keyof KeyedListenerMap>(type: T, key: string, listener: KeyedListenerMap[T]) => void;
14export type ChildActionListener = (action: NavigationAction, visitedNavigators?: Set<string>) => boolean;
15export type FocusedNavigationCallback<T> = (navigation: NavigationHelpers<ParamListBase>) => T;
16export type FocusedNavigationListener = <T>(callback: FocusedNavigationCallback<T>) => {
17 handled: boolean;
18 result: T;
19};
20export type GetStateListener = () => NavigationState;
21export type ChildBeforeRemoveListener = (action: NavigationAction) => boolean;
22/**
23 * Context which holds the required helpers needed to build nested navigators.
24 */
25declare const NavigationBuilderContext: React.Context<{
26 onAction?: ((action: NavigationAction, visitedNavigators?: Set<string>) => boolean) | undefined;
27 addListener?: AddListener | undefined;
28 addKeyedListener?: AddKeyedListener | undefined;
29 onRouteFocus?: ((key: string) => void) | undefined;
30 onDispatchAction: (action: NavigationAction, noop: boolean) => void;
31 onOptionsChange: (options: object) => void;
32 stackRef?: React.MutableRefObject<string | undefined> | undefined;
33}>;
34export default NavigationBuilderContext;
35//# sourceMappingURL=NavigationBuilderContext.d.ts.map
\No newline at end of file