fix(react): fixng ion-router-outlet ref regresssion (#21786)

This commit is contained in:
Ely Lucas
2020-07-21 08:48:25 -06:00
committed by GitHub
parent dbe6853884
commit f4a08b7ed4
9 changed files with 72 additions and 5 deletions

View File

@ -55,7 +55,6 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
}
async handlePageTransition(routeInfo: RouteInfo) {
// let shouldReRender = false;
// If routerOutlet isn't quite ready, give it another try in a moment
if (!this.routerOutletElement || !this.routerOutletElement.commit) {
@ -172,6 +171,7 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
() => {
this.forceUpdate();
});
return (
<StackContext.Provider value={this.stackContextValue}>
{React.cloneElement(ionRouterOutlet as any, {
@ -179,6 +179,9 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
if (ionRouterOutlet.props.setRef) {
ionRouterOutlet.props.setRef(node);
}
if (ionRouterOutlet.props.forwardedRef) {
ionRouterOutlet.props.forwardedRef.current = node;
}
this.routerOutletElement = node;
const { ref } = ionRouterOutlet as any;
if (typeof ref === 'function') {