Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
<li>
<router-link to="/p_1/absolute-a">/p_1/absolute-a</router-link>
</li>
<li>
<router-link to="/func_comp">/func_comp</router-link>
</li>
</ul>
<button @click="toggleViewName">Toggle view</button>
<RouterView :name="viewName" v-slot="{ Component, route }">
Expand Down
5 changes: 5 additions & 0 deletions packages/playground/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const component = () => {
import LongView from './views/LongView.vue'
import GuardedWithLeave from './views/GuardedWithLeave.vue'
import ComponentWithData from './views/ComponentWithData.vue'
import FuncComp from './views/FuncComp'
import { globalState } from './store'
import { scrollWaiter } from './scrollWaiter'
import RepeatedParams from './views/RepeatedParams.vue'
Expand Down Expand Up @@ -159,6 +160,10 @@ export const router = createRouter({
{ path: 'settings', component },
],
},
{
path: '/func_comp',
component: FuncComp,
},
],
async scrollBehavior(to, from, savedPosition) {
await scrollWaiter.wait()
Expand Down
7 changes: 7 additions & 0 deletions packages/playground/src/views/FuncComp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { h, type FunctionalComponent } from 'vue'

const FuncComp: FunctionalComponent = () => {
return h('div', {}, 'Demo Functional Component')
}

export default FuncComp
4 changes: 3 additions & 1 deletion packages/router/src/RouterView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export const RouterViewImpl = /*#__PURE__*/ defineComponent({

const onVnodeUnmounted: VNodeProps['onVnodeUnmounted'] = vnode => {
// remove the instance reference to prevent leak
if (vnode.component!.isUnmounted) {
const component = vnode.component
// the component instance of functional component is null
if (!component || component.isUnmounted) {
matchedRoute.instances[currentName] = null
}
}
Expand Down