You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect import with ESBuild bundling (must use <Editor.default ... />) #106
When building with esbuild the default import is not a Component and fails to render (react crashes).
Note: This may be an issue with ESBuild and not with react-simple-code-editor but I am listing here so folks can find the workaround.
Expected behaviour
You can import the default export as Editor and render it like a component as <Editor ... />
Workaround
It seems that ESBuild leaves the actual component buried under one more 'default' export so just render with <Editor.default ... /> to workaround the problem.
Code sample
The demo/example code will show this as long as you are trying to bundle with ESBuild
I had this issue trying to render the component in Astro. I'd get this error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Initially, I addressed it by only rendering the component on the client (on my host .astro component: client:only="react"). But I wanted to use client:visible. Unfortunately, the suggested workaround didn't work (since astro dev uses a different renderer than astro build && astro host), so I had to be more flexible:
Activity
Yonom commentedon Jul 15, 2024
what the hell, thanks a lot!
citelao commentedon Mar 29, 2025
I had this issue trying to render the component in Astro. I'd get this error:
Initially, I addressed it by only rendering the component on the client (on my host
.astrocomponent:client:only="react"). But I wanted to useclient:visible. Unfortunately, the suggested workaround didn't work (sinceastro devuses a different renderer thanastro build && astro host), so I had to be more flexible:This works correctly for
astro devandastro build && astro host.