SolidJSS
SolidJS5mo ago
23 replies
hyperknot

Make component with only innerHTML

I'd like to make a SolidJS component with only innerHTML.

This is what I have currently, but I'd love to get rid of the <div>

<div innerHTML={sanitizeHtml(props.token.content)} />


The reason is that I'm getting "tokens" from my Markdown processor, which is like a h1, h2, etc. level splitting of the document.

I'm displaying those tokens in a For component in Solid.

The above, div based component works, but breaks CSS, so I cannot write sibling selectors, everything is now wrapped in a dummy div.

Is there any possible way in Solid, which would allow me not to put those dummy divs?

Ideally I'd love to do something like this, similar to <> and </>.

< innerHTML={sanitizeHtml(props.token.content)} />


Is this possible to do something like this in Solid?

The reason I'm using a for loop over a Markdown token list is fine-grained reactivity, I only want to update the last part of the document, as the streaming Markdown comes in.
Was this page helpful?