babel-plugin-jsx icon indicating copy to clipboard operation
babel-plugin-jsx copied to clipboard

[Bug] [Vue warn]: Invalid VNode type: undefined (undefined)

Open wenfangdu opened this issue 4 years ago • 5 comments

🐛 Bug description

Repro: https://github.com/wenfangdu/el-plus-repro/tree/invalid-vnode-type

Please clone the repo and run it.

Source:

import { defineComponent } from 'vue'

const Comp = defineComponent({
  setup(props, { slots }) {
    return () => (
      <div>
        Comp
        {slots.default()}
      </div>
    )
  },
})

export default defineComponent({
  setup() {
    //                                      👇 spreading an empty object will cause this issue
    return () => <Comp>{{ default: () => 1, ...{} }}</Comp>
  },
})

Warning:

runtime-core.esm-bundler.js?5c40:38 [Vue warn]: Invalid VNode type: undefined (undefined)
  at <Anonymous>
  at <App>

🏞 Desired result

No warnings.

wenfangdu avatar May 24 '21 06:05 wenfangdu

@Amour1688 I've updated the repro to be as minimal as possible, please have a look.

wenfangdu avatar Aug 06 '21 14:08 wenfangdu

it's weird.

Amour1688 avatar Aug 06 '21 15:08 Amour1688

@Amour1688 Yes, it is. Using Object.assign would have no problem, only spreading throws:

export default defineComponent({
  setup() {
    //                  👇 no problem
    return () => <Comp>{Object.assign({ default: () => 1 }, {})}</Comp>
  },
})

wenfangdu avatar Aug 07 '21 01:08 wenfangdu

You can use <Comp v-slots={{ default: () => 1, ...{} }} /> temporarily

Amour1688 avatar Aug 07 '21 13:08 Amour1688

我也出现了这个问题,虽然不影响程序执行,但是这个警告却是看着不舒服 我只是简单的写了一个hellworld.tsx 然后在app.tsx import 进来使用 结果也跟你一样的警告提示

seechangan avatar Jan 08 '24 06:01 seechangan