fix(react): duplicate page transitions do not happen on react 18 (#25798)

resolves #25797
This commit is contained in:
Liam DeBeasi
2022-08-23 13:19:38 -05:00
committed by GitHub
parent 30200051bb
commit a39d776f08
2 changed files with 23 additions and 3 deletions

View File

@ -206,8 +206,18 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
registerIonPage(page: HTMLElement, routeInfo: RouteInfo) {
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);
}