question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VNode.componentInstance is undefined when rendered by a functional component

See original GitHub issue

Version

2.5.17-beta.0 2.5.16

Reproduction link

https://codepen.io/anon/pen/rKwWXq?editors=1010

Steps to reproduce

Open the console

What is expected?

An instance of MyComponent should be logged

What is actually happening?

undefined is logged


This worked in 2.5.15 It also works if you change RootComponent to be non-functional:

const content = h(MyComponent, {}, this.slots.default)

I’m guessing this was caused by 62a922e8, cloneVNode doesn’t include that property.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
edlefebvrecommented, Jun 19, 2020

@KaelWD Did you solve this issue? The componentInstance is also undefined when I use named slot like:

A component template

<template v-slot:body>
  <test>Hello world</test>
</template>

B component template

<div>
  <slot name="body"></slot>
</div>

B component script

export default {
  mounted () {
    console.log(this.$slots.body)
  }
}

Quite an old issue I know… but did you find a solution @sc0Vu ?

3reactions
sc0Vucommented, Aug 4, 2019

@KaelWD Did you solve this issue? The componentInstance is also undefined when I use named slot like:

A component template

<template v-slot:body>
  <test>Hello world</test>
</template>

B component template

<div>
  <slot name="body"></slot>
</div>

B component script

export default {
  mounted () {
    console.log(this.$slots.body)
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Component instance is undefined - Stack Overflow
Try setTimeout(() => console.log(item.componentInstance), 150) is it still undefind? – Dani R · @Dani R. I checked it. It is mot undefined. But...
Read more >
VNode.componentInstance is undefined when rendered by a ...
VNode.componentInstance is undefined when rendered by a functional component.
Read more >
Render Functions & JSX | Vue.js
Vue provides an h() function for creating vnodes: js import { h } from 'vue' const ... The render() function has access to...
Read more >
https://np.edu/_resources/js/build/wy.bundle.js.map
components /well-yes/wyform.vue?916d","webpack:///components/well-yes/app.vue" ... n\nexport default function normalizeComponent (\n scriptExports,\n render ...
Read more >
vue.js - Source code - Greasy Fork
'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ... generated render function is guaranteed to return Array<VNode>.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found