UNPKG

1.44 kBTypeScriptView Raw
1import type { NavigationAction, NavigationState, PartialState, Router, RouterConfigOptions } from '@react-navigation/routers';
2import { ChildActionListener, ChildBeforeRemoveListener } from './NavigationBuilderContext';
3import type { EventMapCore } from './types';
4import type { NavigationEventEmitter } from './useEventEmitter';
5declare type Options = {
6 router: Router<NavigationState, NavigationAction>;
7 key?: string;
8 getState: () => NavigationState;
9 setState: (state: NavigationState | PartialState<NavigationState>) => void;
10 actionListeners: ChildActionListener[];
11 beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>;
12 routerConfigOptions: RouterConfigOptions;
13 emitter: NavigationEventEmitter<EventMapCore<any>>;
14};
15/**
16 * Hook to handle actions for a navigator, including state updates and bubbling.
17 *
18 * Bubbling an action is achieved in 2 ways:
19 * 1. To bubble action to parent, we expose the action handler in context and then access the parent context
20 * 2. To bubble action to child, child adds event listeners subscribing to actions from parent
21 *
22 * When the action handler handles as action, it returns `true`, otherwise `false`.
23 */
24export default function useOnAction({ router, getState, setState, key, actionListeners, beforeRemoveListeners, routerConfigOptions, emitter, }: Options): (action: NavigationAction, visitedNavigators?: Set<string>) => boolean;
25export {};