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

@ -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',