gloriasoft / veaury

Use React in Vue3 and Vue3 in React, And as perfect as possible!
MIT License
1.31k stars 83 forks source link

Using tsx file inside vue app #45

Closed Lafa02 closed 1 year ago

Lafa02 commented 1 year ago

Hi I'm trying to use some tsx components inside my react app, but the console gives me a weird error

Note: I'm using quasar with vue my Hello.react.tsx import React from 'react'; export default const HelloReact = (name: string) => { return <div>Hello {name}, I am a React component</div>; } my app.vue `

this is my """webpack""": ` image

and this is the error image I'm doing something wrong for sure, but I have no idea what

devilwjp commented 1 year ago

@Lafa02 The parameter type of the function component Hello.react.tsx seems to be incorrect. The parameter of the function component accepts a object, not a string.
I think the correct code should be as follows:

const HelloReact = ({name}) => { return <div>Hello {name}, I am a React component</div>; }

Then, I also noticed that the error message also mentioned found object with keys {name, children},..., which means that the parameter name of the incorrect react function component you provided earlier is actually a Object, not a string, this object contains two keys name and children, this object cannot be rendered directly, you should render the name property of this object.

Lafa02 commented 1 year ago

I'm so stupid, sorry, thank you so much!