UNPKG

1.07 kBTypeScriptView Raw
1import type { NavigationState, PartialState } from '@react-navigation/routers';
2import type { PathConfigMap } from './types';
3declare type Options<ParamList> = {
4 initialRouteName?: string;
5 screens: PathConfigMap<ParamList>;
6};
7declare type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>;
8/**
9 * Utility to serialize a navigation state object to a path string.
10 *
11 * @example
12 * ```js
13 * getPathFromState(
14 * {
15 * routes: [
16 * {
17 * name: 'Chat',
18 * params: { author: 'Jane', id: 42 },
19 * },
20 * ],
21 * },
22 * {
23 * screens: {
24 * Chat: {
25 * path: 'chat/:author/:id',
26 * stringify: { author: author => author.toLowerCase() }
27 * }
28 * }
29 * }
30 * )
31 * ```
32 *
33 * @param state Navigation state to serialize.
34 * @param options Extra options to fine-tune how to serialize the path.
35 * @returns Path representing the state, e.g. /foo/bar?count=42.
36 */
37export default function getPathFromState<ParamList extends {}>(state: State, options?: Options<ParamList>): string;
38export {};