diff --git a/packages/router/src/utils/preactivation.ts b/packages/router/src/utils/preactivation.ts index 2f56a177aa..3b3dd31d6a 100644 --- a/packages/router/src/utils/preactivation.ts +++ b/packages/router/src/utils/preactivation.ts @@ -121,8 +121,8 @@ function getRouteGuards( } if (shouldRun) { - const outlet = context !.outlet !; - checks.canDeactivateChecks.push(new CanDeactivate(outlet.component, curr)); + const component = context && context.outlet && context.outlet.component || null; + checks.canDeactivateChecks.push(new CanDeactivate(component, curr)); } } else { if (curr) {