Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/react-router/src/ReactRouter/StackManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,18 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
registerIonPage(page: HTMLElement, routeInfo: RouteInfo) {
Comment thread
sean-perkins marked this conversation as resolved.
const foundView = this.context.findViewItemByRouteInfo(routeInfo, this.id);
if (foundView) {
const oldPageElement = foundView.ionPageElement;
foundView.ionPageElement = page;
foundView.ionRoute = true;

/**
* React 18 will unmount and remount IonPage
* elements in development mode when using createRoot.
* This can cause duplicate page transitions to occur.
*/
if (oldPageElement === page) {
return;
}
}
this.handlePageTransition(routeInfo);
}
Expand Down
16 changes: 13 additions & 3 deletions packages/react/src/routing/OutletPageManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ export class OutletPageManager extends React.Component<OutletPageManagerProps> {
ionLifeCycleContext!: React.ContextType<typeof IonLifeCycleContext>;
context!: React.ContextType<typeof StackContext>;
ionRouterOutlet: HTMLIonRouterOutletElement | undefined;
outletIsReady: boolean;

constructor(props: OutletPageManagerProps) {
super(props);

this.outletIsReady = false;
}

componentDidMount() {
if (this.ionRouterOutlet) {
componentOnReady(this.ionRouterOutlet, () => {
this.context.registerIonPage(this.ionRouterOutlet!, this.props.routeInfo!);
});
/**
* This avoids multiple raf calls
* when React unmounts + remounts components.
*/
if (!this.outletIsReady) {
componentOnReady(this.ionRouterOutlet, () => {
this.outletIsReady = true;
this.context.registerIonPage(this.ionRouterOutlet!, this.props.routeInfo!);
});
}

this.ionRouterOutlet.addEventListener(
'ionViewWillEnter',
Expand Down