Having trouble rendering JSX into a dom element when loading the SolidJS component as an ESM module #2091
Unanswered
jhallmusic
asked this question in
Q&A
Replies: 1 comment
-
Well, I solved my own issue. My error was using Here's an example function to do so:
then, import this function into the Solid component, and change the esbuild line to including this instead:
One question tho - am I missing that this function is somewhere in SolidJS already? It doesn't seem to be, as I looked all over for it. But if so, maybe I just missed it? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi - Hopefully this is the right place to ask about this. I'm using ESBuild to bundle a SolidJS component and then I'm importing that into a separate Javascript file. Finally, trying to get that component to render into the DOM. Everything seems to be working except for the actual rendering of the HTML. Here's a sample of how I'm doing it:
The JS file for the SolidJS component:
Note, I've tried several different ways of doing the last bit of code, including using
Solid.createRoot
.If I use the first line that is commented out (
render(() => <SolidComponent />, root);
), the component never actually mounts. The line that is not commented out seems to work better (the component does mount).But nothing I have tried actually gets the
<div>Test</div>
to render inside the dom element I've targeted. I have confirmed that the component can properly target that element (I've loggedroot
and it shows the proper dom element I have in the html file.)Here is how I'm loading the module itself, inside of the JS file:
This seems to properly load the module because there are no errors, and I see the console log 'loaded' message.
Finally, this is how the component is being bundled:
I've tried so many different ways to get this to work, and nothing I try actually renders any html. The "test" div is empty no matter what.
Am I doing something wrong here? I've done the exact same thing with React components, Vue components, a simple Web Component, etc. Every other component renders properly. Just not sure why this
return
statement doesn't seem to be doing anything.Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions