Subscribe on changes!

Warn when vnodes are accidentally reused

avatar
Sep 25th 2020

Version

3.0.0

Reproduction link

https://codepen.io/bastarder/pen/gOrqNoG

Steps to reproduce

i saw the document say All VNodes in the component tree must be unique. That means the following render function is invalid see here

<script>
import { h } from 'vue'

export default {
  render() {
    const myParagraphVNode = h('p', 'hi')
    return h('div', [
      myParagraphVNode, myParagraphVNode,
    ])
  },
}
</script>

What is expected?

give some warning

What is actually happening?

both of myParagraphVNode rendered successfully

avatar
Sep 25th 2020

if p was a custom component, also be rendered successfully

avatar
Sep 25th 2020

Vnode can be reused in v3, also in Vue2.5.18+. @posva I think we need to update the documentation.

avatar
Sep 25th 2020

Are you sure? I remember reusing nodes not being possible and one of the reasons to use cloneVnode

avatar
Jan 4th 2021

I think this issue has been resolved and can be closed.