Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid VNode type: undefined (undefined) - when used with <component :is="comp">

I have been stuck on this issue for a while with no information online. using vue 3

  • I define a layout component inside my router meta: tag.

  • Inside my App.vue I check if a specified route has the layout meta tag, and if so the `component :is="layout" is true.

App.vue

<template>
  <component :is="layout">
    <router-view />
  </component>
</template>

<script>
  computed: {
    layout() {
      let layout = null;
      for (const match of this.$route.matched)
        if (match.meta && match.meta.layout) layout = match.meta.layout;
      if (layout) return layout;
      return "div";
    },
}
</script>

router.vue

const usLayout = () => import("../layouts/usLayout.vue");

    {
      path: "/",
      name: "us",
      component: GenericRouterView,
      meta: { layout: usLayout },
      children: usRoutes,
    },

I get this error:

[Vue warn]: Invalid VNode type: undefined (undefined) at UsLayout at App

And nothing is displayed on the screen. Any ideas what this error means / what causes it?

like image 304
babis95 Avatar asked Jun 10 '26 17:06

babis95


1 Answers

I had this error when I migrated to Vue3 and did not wrap my lazy loaded Async Components in the new helper function defineAsyncComponent.

Error

const PdfViewer = () => import('@frontend/components/pdf-viewer.vue')

Works

const PdfViewer = defineAsyncComponent(() => import('@frontend/components/pdf-viewer.vue'))
like image 164
Steven Spungin Avatar answered Jun 13 '26 18:06

Steven Spungin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!