Hacker News new | ask | show | jobs
by willio58 932 days ago
I completely agree. Recently I listened to a podcast where Brad Frost talked about web components being useful for design systems, as you can make a button in a web component and have that defined no matter what JS framework the dev team (or teams) want to use company-wide.

One issue I see though and I almost feel dumb for saying it, I don't like how web component code looks. Using innerHTML feels really weird when your team is so used to using JSX for react components for example. I don't think this would stop me from researching web components more but does anyone feel similarly or have a solution or obvious answer for me in this area?

3 comments

You don't have to use innerHtml. The ShadowRoot pretty much acts like a document. So you can also use appendChild. Combined with a template element you can completely avoid innheHtml. You could even use jsx to create the template element I suppose.

That said I think this is mostly a non-issue.

For me, it feels weird to have four file types I need to manage in order to define a UI, instead of just one.
lit [1] provides declarative templates for web components for example.

[1] https://lit.dev/