Doug Parker · @develwithoutacause
236 followers · 940 posts · Server techhub.social

Playing a bit with / today and am feeling the pain of not having host elements. I've realized that because a "component" is really just a template, there is no implicit contract around what it actually rendered.

As an arbitrary example, what if I want to set a style on a `<Foo />` component? What selector should I use for that style? I have no idea what `<Foo />` will actually generate, or even how many top-level elements it will output. The `Foo` component _must_ expose some kind of `className` or other API to provide this behavior, it's not implicit at all.

Maybe this is good because it provides stronger encapsulation. But it can also lead to bugs. If I render `<Header />` a `header` CSS selector is _probably_ right. But what if `<Header />` actually renders:

<div>
<header>...</header>
</div>

Then a `header` selector isn't actually the top-level element and my style could easily be wrong.

Just some idle thoughts about the lack of host elements.

#preact #jsx #vdom

Last updated 1 year ago

Doug Parker · @develwithoutacause
201 followers · 615 posts · Server techhub.social

Apparently (or / ) cannot directly render comments: github.com/preactjs/preact/iss

I get why that's not super useful in a client-side context, but particularly for server-side rendering use cases I would expect to be able to render comments. I would expect to be able to render any arbitrary DOM structure, but I guess that's not possible out of the box?

Not sure if there any workarounds to render comments in Preact. I'm not immediately able to find anything, might be a challenge to work around.

#preact #jsx #vdom

Last updated 1 year ago