in src/components/router/router.tsx [112:158]
navigate(routeName: string, props: Record<string, any>, {forceReset = false} = {}) {
log.info(`Router(navigate): -> ${routeName}`);
if (!this.routes[routeName]) {
throw `no such route ${routeName}`;
}
if (!this._navigator) {
log.info(`Router(navigate): navigator not ready, queueing navigation to ${routeName}`);
this._pendingNavigation = () => this.navigate(routeName, props, {forceReset});
return;
}
if (this.rootRoutes.includes(routeName) || props?.store === true) {
flushStoragePart({lastRoute: props?.storeRouteName || routeName});
}
const newRoute = Object.assign({}, this.routes[routeName]);
newRoute.props = Object.assign({}, newRoute.props, props);
const prevRouteName: string | undefined = this._currentRoute?.routeName;
const navigationData: NavigationNavigateAction = NavigationActions.navigate({
routeName,
params: newRoute.props,
key: routeName,
});
if (newRoute.type === 'reset' || forceReset) {
try {
if (this._navigator && isIOSPlatform()) {
this._navigator._navigation.dismiss();
}
} catch (e) {
log.info('Router:(navigate dismiss)', e);
}
this.dispatch(
StackActions.reset({
index: 0,
actions: [navigationData],
key: null,
}),
routeName,
prevRouteName
);
} else {
this.dispatch(navigationData, routeName, prevRouteName);
}
}