@react-navigation/routers 7.0.0-alpha.6 → 7.0.0-rc.1
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/lib/commonjs/BaseRouter.js.map +1 -1
- package/lib/commonjs/CommonActions.js +10 -10
- package/lib/commonjs/CommonActions.js.map +1 -1
- package/lib/commonjs/DrawerRouter.js +14 -17
- package/lib/commonjs/DrawerRouter.js.map +1 -1
- package/lib/commonjs/StackRouter.js +14 -60
- package/lib/commonjs/StackRouter.js.map +1 -1
- package/lib/commonjs/TabRouter.js +22 -27
- package/lib/commonjs/TabRouter.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/BaseRouter.js.map +1 -1
- package/lib/module/CommonActions.js +10 -10
- package/lib/module/CommonActions.js.map +1 -1
- package/lib/module/DrawerRouter.js +14 -17
- package/lib/module/DrawerRouter.js.map +1 -1
- package/lib/module/StackRouter.js +14 -60
- package/lib/module/StackRouter.js.map +1 -1
- package/lib/module/TabRouter.js +22 -27
- package/lib/module/TabRouter.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/BaseRouter.d.ts +22 -11
- package/lib/typescript/src/BaseRouter.d.ts.map +1 -1
- package/lib/typescript/src/DrawerRouter.d.ts +1 -1
- package/lib/typescript/src/StackRouter.d.ts +0 -27
- package/lib/typescript/src/StackRouter.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/StackRouter.tsx +0 -76
- package/src/TabRouter.tsx +1 -1
package/src/StackRouter.tsx
CHANGED
|
@@ -44,20 +44,6 @@ export type StackActionType =
|
|
|
44
44
|
};
|
|
45
45
|
source?: string;
|
|
46
46
|
target?: string;
|
|
47
|
-
}
|
|
48
|
-
| {
|
|
49
|
-
type: 'REMOVE';
|
|
50
|
-
payload: {
|
|
51
|
-
name: string;
|
|
52
|
-
params?: object;
|
|
53
|
-
};
|
|
54
|
-
source?: string;
|
|
55
|
-
target?: string;
|
|
56
|
-
}
|
|
57
|
-
| {
|
|
58
|
-
type: 'RETAIN';
|
|
59
|
-
source?: string;
|
|
60
|
-
target?: string;
|
|
61
47
|
};
|
|
62
48
|
|
|
63
49
|
export type StackRouterOptions = DefaultRouterOptions;
|
|
@@ -132,29 +118,6 @@ export type StackActionHelpers<ParamList extends ParamListBase> = {
|
|
|
132
118
|
| [screen: RouteName, params: ParamList[RouteName], merge: boolean]
|
|
133
119
|
: never
|
|
134
120
|
): void;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Remove a screen from the preloaded list in the navigator.
|
|
138
|
-
*
|
|
139
|
-
* @param name Name of the route to remove preload.
|
|
140
|
-
* @param [params] Params object for the route.
|
|
141
|
-
*/
|
|
142
|
-
remove<RouteName extends keyof ParamList>(
|
|
143
|
-
...args: RouteName extends unknown
|
|
144
|
-
? undefined extends ParamList[RouteName]
|
|
145
|
-
?
|
|
146
|
-
| [screen: RouteName]
|
|
147
|
-
| [screen: RouteName, params: ParamList[RouteName]]
|
|
148
|
-
: [screen: RouteName, params: ParamList[RouteName]]
|
|
149
|
-
: never
|
|
150
|
-
): void;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Removes a screen from the active routes, at the same time
|
|
154
|
-
* retaining the screen in the preloaded screens list,
|
|
155
|
-
* so it is not getting detached.
|
|
156
|
-
*/
|
|
157
|
-
retain(): void;
|
|
158
121
|
};
|
|
159
122
|
|
|
160
123
|
export const StackActions = {
|
|
@@ -173,12 +136,6 @@ export const StackActions = {
|
|
|
173
136
|
popTo(name: string, params?: object, merge?: boolean): StackActionType {
|
|
174
137
|
return { type: 'POP_TO', payload: { name, params, merge } };
|
|
175
138
|
},
|
|
176
|
-
remove(name: string, params?: object): StackActionType {
|
|
177
|
-
return { type: 'REMOVE', payload: { name, params } };
|
|
178
|
-
},
|
|
179
|
-
retain(): StackActionType {
|
|
180
|
-
return { type: 'RETAIN' };
|
|
181
|
-
},
|
|
182
139
|
};
|
|
183
140
|
|
|
184
141
|
export function StackRouter(options: StackRouterOptions) {
|
|
@@ -747,40 +704,7 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
747
704
|
};
|
|
748
705
|
}
|
|
749
706
|
}
|
|
750
|
-
case 'RETAIN': {
|
|
751
|
-
const index =
|
|
752
|
-
action.target === state.key && action.source
|
|
753
|
-
? state.routes.findIndex((r) => r.key === action.source)
|
|
754
|
-
: state.index;
|
|
755
|
-
|
|
756
|
-
if (index === -1) {
|
|
757
|
-
return null;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
const route = state.routes[index];
|
|
761
707
|
|
|
762
|
-
const routes = state.routes.filter((r) => r !== route);
|
|
763
|
-
return {
|
|
764
|
-
...state,
|
|
765
|
-
index: routes.length - 1,
|
|
766
|
-
routes,
|
|
767
|
-
preloadedRoutes: state.preloadedRoutes.concat(route),
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
case 'REMOVE': {
|
|
772
|
-
const getId = options.routeGetIdList[action.payload.name];
|
|
773
|
-
const id = getId?.({ params: action.payload.params });
|
|
774
|
-
|
|
775
|
-
return {
|
|
776
|
-
...state,
|
|
777
|
-
preloadedRoutes: state.preloadedRoutes.filter(
|
|
778
|
-
(route) =>
|
|
779
|
-
route.name !== action.payload.name ||
|
|
780
|
-
id !== getId?.({ params: route.params })
|
|
781
|
-
),
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
708
|
default:
|
|
785
709
|
return BaseRouter.getStateForAction(state, action);
|
|
786
710
|
}
|
package/src/TabRouter.tsx
CHANGED
|
@@ -386,7 +386,7 @@ export function TabRouter({
|
|
|
386
386
|
return null;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
const previousKey = state.history[state.history.length - 2]
|
|
389
|
+
const previousKey = state.history[state.history.length - 2]?.key;
|
|
390
390
|
const index = state.routes.findIndex(
|
|
391
391
|
(route) => route.key === previousKey
|
|
392
392
|
);
|