React.jsx: type is invalid.

Hey! Recently converted an extension I was developing from custom React to Plasmo + React. I have a contents folder with VideoBadge.tsx(the main component that gets mounted into pages) + a components folder where I store all the components for VideoBadge. The thing is that when I edit something inside the components folder and reload, this always happens. Everything works fine but this error appears
21 Replies
davidgonmar
davidgonmarOP•2y ago
After some digging its kind of trying to render 2 content elements even though there is only one in the root of contents Is this a bug or how can I fix that?
lab
lab•2y ago
Are you manually mounting your react root? if so, you should use the ts file extension instead. With the tsx extension, Plasmo mount it all for you via the CSUI feature
lab
lab•2y ago
Plasmo Docs
Migrate to Plasmo Framework – Plasmo
A guide on migrating to Plasmo from any browser extension setup.
lab
lab•2y ago
See this docs for more info on migrating to Plasmo
davidgonmar
davidgonmarOP•2y ago
My contents folder looks like this: -contents -VideoBadge.tsx -components But somehow whenever I change some code on the components folder with the dev server(hmr) enabled, Plasmo will try to mount that component independently, which should not happen since it is not in the root of /components/ if I am not mistaken @louis
Arcane
Arcane•2y ago
@davidgm has reached level 1. GG!
davidgonmar
davidgonmarOP•2y ago
If I restart the server everything works fine, but its annoying
lab
lab•2y ago
Oh, any files residing in contents are treated as entry files You should move any file that you don't wish to be CS/CSUI outside contents
davidgonmar
davidgonmarOP•2y ago
Then I think there might be a bug. Plasmo only tries to mount it(and gives an error since they are not really thought to be mounted that way) when I am on the dev server and edit them If that condition is not met plasmo just mounts the component in the root of /contents but files inside folders do not get touched at all What is the expected behaviour? Thanks for the help btw:)
lab
lab•2y ago
are the stuff inside /components also CSUI entries?
davidgonmar
davidgonmarOP•2y ago
Not really intended to. They are just regular 'export const whatever' React Components @louis
lab
lab•2y ago
yeah you will need to relocate them we dont' have colocation atm, observing nextjs transition to the app dir
davidgonmar
davidgonmarOP•2y ago
Ok thanks:) but any idea on why it works fine as long as I dont edit their files while in dev server?
lab
lab•2y ago
in dev server, we track them for reloading in prod, they are just statically bundled
davidgonmar
davidgonmarOP•2y ago
And even on production it works fine
lab
lab•2y ago
yup, I would expect it to work as well if you don't export default anything from those comp
davidgonmar
davidgonmarOP•2y ago
Yeah I dont But it still tries to mount it and gets undefined of course(since it doesnt export default anything)
lab
lab•2y ago
the dev server provides HMR, live-reloading as well as CSUI mount based on known entry directory, thus you might see error or duplicated mount. The idea of the contents directory is parallel to the pages directory in nextjs i.e, in nextjs's page directory, you might seen something similar too where an utils.tsx file wasn't supposed to be a page, but it get rendered anyway
davidgonmar
davidgonmarOP•2y ago
Alright
Arcane
Arcane•2y ago
@davidgm has reached level 2. GG!
davidgonmar
davidgonmarOP•2y ago
Thanks for explaining:) Have a good day louis!
Want results from more Discord servers?
Add your server