UNPKG

1.12 kBTypeScriptView Raw
1import type { NavigationState, PartialState } from '@react-navigation/routers';
2import type { PathConfigMap } from './types';
3type Options<ParamList extends {}> = {
4 initialRouteName?: string;
5 screens: PathConfigMap<ParamList>;
6};
7type 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 {};
39//# sourceMappingURL=getPathFromState.d.ts.map
\No newline at end of file