@react-navigation/routers 8.0.0-alpha.0 → 8.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/TabRouter.tsx CHANGED
@@ -14,9 +14,9 @@ import type {
14
14
 
15
15
  export type TabActionType = {
16
16
  type: 'JUMP_TO';
17
- payload: { name: string; params?: object };
18
- source?: string;
19
- target?: string;
17
+ payload: { name: string; params?: object | undefined };
18
+ source?: string | undefined;
19
+ target?: string | undefined;
20
20
  };
21
21
 
22
22
  export type BackBehavior =
@@ -37,7 +37,7 @@ export type TabRouterOptions = DefaultRouterOptions & {
37
37
  * - `fullHistory` - return to last visited route; doesn't drop duplicate entries unlike `history` - matches behavior of web pages
38
38
  * - `none` - do not handle going back
39
39
  */
40
- backBehavior?: BackBehavior;
40
+ backBehavior?: BackBehavior | undefined;
41
41
  };
42
42
 
43
43
  export type TabNavigationState<ParamList extends ParamListBase> = Omit<
@@ -4,7 +4,7 @@ type Options = {
4
4
  action: {
5
5
  payload: {
6
6
  name: string;
7
- params?: object;
7
+ params?: object | undefined;
8
8
  };
9
9
  };
10
10
  routeParamList: ParamListBase;
@@ -7,7 +7,7 @@ type Options = {
7
7
  action: {
8
8
  payload: {
9
9
  name: string;
10
- params?: object;
10
+ params?: object | undefined;
11
11
  };
12
12
  };
13
13
  routeParamList: ParamListBase;
package/src/types.tsx CHANGED
@@ -6,7 +6,7 @@ export type NavigationRoute<
6
6
  ParamList extends ParamListBase,
7
7
  RouteName extends keyof ParamList,
8
8
  > = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
9
- state?: NavigationState | PartialState<NavigationState>;
9
+ state?: NavigationState | PartialState<NavigationState> | undefined;
10
10
  };
11
11
 
12
12
  export type NavigationState<ParamList extends ParamListBase = ParamListBase> =
@@ -26,7 +26,7 @@ export type NavigationState<ParamList extends ParamListBase = ParamListBase> =
26
26
  /**
27
27
  * Alternative entries for history.
28
28
  */
29
- history?: unknown[];
29
+ history?: unknown[] | undefined;
30
30
  /**
31
31
  * List of rendered routes.
32
32
  */
@@ -45,20 +45,22 @@ export type NavigationState<ParamList extends ParamListBase = ParamListBase> =
45
45
 
46
46
  export type InitialState = Readonly<
47
47
  Partial<Omit<NavigationState, 'stale' | 'routes'>> & {
48
- routes: (Omit<Route<string>, 'key'> & { state?: InitialState })[];
48
+ routes: (Omit<Route<string>, 'key'> & {
49
+ state?: InitialState | undefined;
50
+ })[];
49
51
  }
50
52
  >;
51
53
 
52
54
  export type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
53
- key?: string;
54
- state?: PartialState<NavigationState>;
55
+ key?: string | undefined;
56
+ state?: PartialState<NavigationState> | undefined;
55
57
  };
56
58
 
57
59
  export type PartialState<State extends NavigationState> = Partial<
58
60
  Omit<State, 'stale' | 'routes'>
59
61
  > &
60
62
  Readonly<{
61
- stale?: true;
63
+ stale?: true | undefined;
62
64
  routes: PartialRoute<Route<State['routeNames'][number]>>[];
63
65
  }>;
64
66
 
@@ -79,18 +81,18 @@ export type Route<
79
81
  * Path associated with the route.
80
82
  * Usually present when the screen was opened from a deep link.
81
83
  */
82
- path?: string;
84
+ path?: string | undefined;
83
85
  /**
84
86
  * History of param changes for this route.
85
87
  */
86
- history?: { type: 'params'; params: object }[];
88
+ history?: { type: 'params'; params: object }[] | undefined;
87
89
  } & Readonly<
88
90
  undefined extends Params
89
91
  ? {
90
92
  /**
91
93
  * Params for this route
92
94
  */
93
- params?: Readonly<Params>;
95
+ params?: Readonly<Params> | undefined;
94
96
  }
95
97
  : {
96
98
  /**
@@ -111,15 +113,15 @@ export type NavigationAction = Readonly<{
111
113
  /**
112
114
  * Additional data for the action
113
115
  */
114
- payload?: object;
116
+ payload?: object | undefined;
115
117
  /**
116
118
  * Key of the route which dispatched this action.
117
119
  */
118
- source?: string;
120
+ source?: string | undefined;
119
121
  /**
120
122
  * Key of the navigator which should handle this action.
121
123
  */
122
- target?: string;
124
+ target?: string | undefined;
123
125
  }>;
124
126
 
125
127
  export type ActionCreators<Action extends NavigationAction> = {
@@ -131,7 +133,7 @@ export type DefaultRouterOptions<RouteName extends string = string> = {
131
133
  * Name of the route to focus by on initial render.
132
134
  * If not specified, usually the first route is used.
133
135
  */
134
- initialRouteName?: RouteName;
136
+ initialRouteName?: RouteName | undefined;
135
137
  };
136
138
 
137
139
  export type RouterFactory<
@@ -145,7 +147,9 @@ export type RouterConfigOptions = {
145
147
  routeParamList: ParamListBase;
146
148
  routeGetIdList: Record<
147
149
  string,
148
- | ((options: { params?: Record<string, any> }) => string | undefined)
150
+ | ((options: {
151
+ params?: Record<string, any> | undefined;
152
+ }) => string | undefined)
149
153
  | undefined
150
154
  >;
151
155
  };