diff --git a/packages/router/src/RouterView.tsx b/packages/router/src/RouterView.tsx index b66cea1c..b1ae9679 100644 --- a/packages/router/src/RouterView.tsx +++ b/packages/router/src/RouterView.tsx @@ -24,7 +24,7 @@ export function RouterView({ router }: RouterViewProps) { progress: number; }>({ previous: null, - current: router.current ? router._wrapScreen(router.current) : null, + current: router.current ? router.wrapScreen(router.current) : null, direction: 'push', progress: 1, }); diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 318c4118..875310ad 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -177,7 +177,8 @@ export class Router { } } - _wrapScreen(match: RouteMatch): VNode { + /** Wrap a route match into a VNode with layout chain and providers */ + wrapScreen(match: RouteMatch): VNode { let screen = createElement(match.route.component, match.params); for (let i = match.chain.length - 2; i >= 0; i--) { @@ -267,7 +268,7 @@ export class Router { const notFoundMatch = this._createNotFoundMatch(resolvedPath); this._currentMatch = notFoundMatch; if (this.autoUnmount) unmountAll(); - const screen = this._wrapScreen(notFoundMatch); + const screen = this.wrapScreen(notFoundMatch); const emitEvent = direction === 'back' ? 'back' : 'navigate'; this.events.emit(emitEvent, { match: notFoundMatch, screen, direction }); return; @@ -310,7 +311,7 @@ export class Router { this._currentMatch = match; if (this.autoUnmount) unmountAll(); - const screen = this._wrapScreen(match); + const screen = this.wrapScreen(match); const emitEvent = direction === 'back' ? 'back' : 'navigate'; this.events.emit(emitEvent, { match, screen, direction }); @@ -379,7 +380,7 @@ export class Router { this._currentMatch = match; if (this.autoUnmount) unmountAll(); - const screen = this._wrapScreen(match); + const screen = this.wrapScreen(match); this.events.emit('back', { match, screen, direction: 'back' }); @@ -414,7 +415,7 @@ export class Router { this._history.push(nextPath); this._currentMatch = match; if (this.autoUnmount) unmountAll(); - const screen = this._wrapScreen(match); + const screen = this.wrapScreen(match); this.events.emit('navigate', { match, screen, direction: 'forward' }); match.route.afterEnter?.(nextPath);