Live data from Hacker News

Why I don't miss React: a story about using the platform

jackfranklin.co.uk

241–250 of 279 posts

Re: Why I don't miss React: a story about using the platform

#241
post #106
post #30

Come on over rovers: https://github.com/cheatcode/joystick . I promise you'll love it if you're switching from React (pure HTML, CSS, and JavaScript w/ minimal abstraction). And it's full-stack so no more stitching together frankenstacks. Good ol' isomorphic JS for devs who value their time/productivity.

Hard to say it's a good sell coming from React when the component API has been twice-replaced by better options in the React world. This looks awfully tedious to use.

Tedious? It's as straightforward as you can get (by design). React has devolved into an utter mess of ambiguous patterns and unnecessary abstractions that make the work far more difficult than it needs to be.

Re: Why I don't miss React: a story about using the platform

#242

> Was this slightly more work than using a library from npm? > I'd definitely recommend using a library for this, and we settled on lit-html (link to library from npm) This article is mostly about switching from React to Lit. You can use modern web APIs (like FormData) with React, FormData's not a replacement for state management. You can use Web Components with React, the way Fluent UI does ( https://docs.microsoft.…

> This article is mostly about switching from React to Lit. I'll freely admit I'm a backend guy and don't know much about JavaScript frameworks, but the author emphasizes they didn't use Lit, just lit-html, and for the same reasons they didn't use React. Is lit-html really such a huge portion of Lit that you disagree with their own assessment of what they've done?

They combine lit-html with a "basic scheduler" that they've written themselves. I'm guessing that's intended as a replacement for React, but it could easily be seen as a replacement for Lit, which offers "reactive properties" too.

I think how they gloss over the "we'll just write a library to handle component rendering, lifecycle and state" portion as a "basic scheduler" is a bit disingenuous. The author even mentions they are essentially recreating some features of React, but felt it was worth the tradeoff.

Re: Why I don't miss React: a story about using the platform

#243
Few of the comments seem to focus on Lit, the "anti-framework," which is a very valid alternative.

In Lit, there are *no* pre-built components. No boxes or buttons or controls or routing. None. You make what you need.

Sounds daunting but, as the author points out, it frees you from cruft. You make only what you need. YOU design the API and syntax. And you add/remove whatever you want, whenever.

It would be hard for me to go back to canned components after Lit! Try the interactive tutorial:

https://lit.dev/tutorial/

Re: Why I don't miss React: a story about using the platform

#244

Earlier quoted context omitted.

> This article is mostly about switching from React to Lit. I'll freely admit I'm a backend guy and don't know much about JavaScript frameworks, but the author emphasizes they didn't use Lit, just lit-html, and for the same reasons they didn't use React. Is lit-html really such a huge portion of Lit that you disagree with their own assessment of what they've done?

They combine lit-html with a "basic scheduler" that they've written themselves. I'm guessing that's intended as a replacement for React, but it could easily be seen as a replacement for Lit, which offers "reactive properties" too. I think how they gloss over the "we'll just write a library to handle component rendering, lifecycle and state" portion as a "basic scheduler" is a bit disingenuous. The author even mention…

There is no doubt that, when using Lit, you're going to re-write portions of some existing framework. That's the big selling point: You're going to write them your way, and only the ones you need. Instead of inheriting and learning React (or Angular, or Vue), you decide what syntax and behavior your components will have -- all the way down to "bare metal" of when and if they render and with what contents or results. None of this is specified by Lit so you will be re-writing those pre-fab aspects of any canned framework.

You'll also be writing any kind of routing or other validation tools that you need. Which is actually glorious! You get to make one that's small and easy to keep in your own head, yet flexible enough to be extended and expanded in any way that you can imagine.

There isn't a React component that would have helped me build this game[0], other than very basic stuff like buttons. But with Lit, I could write components all they way down to SVG graphical elements and create all kinds of new behaviors that React doesn't understand.

[0] https://hexxedgame.com (100% Lit/TS)

Re: Why I don't miss React: a story about using the platform

#245
post #236
post #217

Tried Lit and StencilJS. They are both forcing the usage of custom events to dispatch functions and share data between components. It's horribly unergonomic. Using the DOM with event bubbling and capturing feels really bad. Orchestrating rendering is a mess. The Shadow DOM and templates don't really solve any issues that aren't already solved with things like CSS modules for style scoping and even using element cloni…

So what do you do? Hand-craft Web Components?

In Lit, yes. It's hand-crafted web components with support for one-way data binding by parameter passing. Any other updates are by event notifications, as the commenter said.

Re: Why I don't miss React: a story about using the platform

#246
post #215

Earlier quoted context omitted.

It fairness you can do reactive data without RxJS. For example by using the vanilla web socket API. Agree that RxJS is best avoided though.

You can react to state changes with an astonishingly small amount of code with JS [0] [0]: https://github.com/curlywurlycraig/vdom-util/blob/master/src...

Link doesn't work for me. 404s

Re: Why I don't miss React: a story about using the platform

#247

Earlier quoted context omitted.

This simply isn't true. Tagged template literals are not string concatenation. Also any "thin layer" of tooling on top of vanilla web components (like Lit) is entirely capable of passing complex objects as props. String-only "props" are only the case for literal HTML attributes in your source HTML—and even then you can embed JSON in an attribute and get a real parsed object within the component.

> Tagged template literals are not string concatenation They are not concatenation by themselves. But for them to be useful, you will end up doing a lot of it because there's nothing else to do with strings than parse (often with regexps [1]) and concatenate [2] the strings. And then you dump the concatenated string into the DOM using `.innerHtml` [3] There's no magic. [1] https://github.com/lit/lit/blob/main/package…

I use Lit every day and I have no idea what you're talking about.

Any property can be a full JS object. When the property is changed, it is re-rendered in your component. I have never touched innerHtml and my Lit apps pass and render all kinds of stuff into html`` tagged templates.

It's really pure magic because you can freely mix regular old HTML and regular attributes with dynamic data and data binding. There's more than one way to write anything which gives you great flexibility. I adore tagged templates, and they work for CSS and SVG, too.

Re: Why I don't miss React: a story about using the platform

#248
post #27

> Was this slightly more work than using a library from npm? > I'd definitely recommend using a library for this, and we settled on lit-html (link to library from npm) This article is mostly about switching from React to Lit. You can use modern web APIs (like FormData) with React, FormData's not a replacement for state management. You can use Web Components with React, the way Fluent UI does ( https://docs.microsoft.…

Anyone know what is going on with lit-? Their TypeScript starter is painfully bloated and outdated and never seems to keep pace. I actually ended up looking at microsoft/fast for my use case but that seems to be stale in some way. I kind of feel that given the "simplicity" of a single class wrapping custom elements, everything is pretty boring. Note: I cannot do better.

I use Lit and have a tiny bit of MS/FAST in one project. You're right. Neither site gets updated. I think both have terrible doc, really. I didn't learn anything from the Lit starter or the intro doc. Only the interactive tutorial was of any use.

I think FAST is dead because MS doesn't want to play keep-up with it. In fact, all of the component libraries that Lit advertises on their home page (https://lit.dev) seem be Thanksgiving leftovers put out on a buffet. No one is seriously updating a set of web components for public use.

But... perhaps that is because Lit isn't really great for making components for others? It doesn't get you out of the work of documenting them, for example, which is already done with canned component libraries. It certainly puts all the fixes back on you.

In my experience, Lit is terrific for green sheet projects and ones where you can keep everything in-house. But there is no "Lit community" or resources for people getting into it who want a jump start. And no great tutorial doc.

Unsurprisingly, you don't see Lit discussed too much anywhere!

Re: Why I don't miss React: a story about using the platform

#249
post #236

Earlier quoted context omitted.

So what do you do? Hand-craft Web Components?

In Lit, yes. It's hand-crafted web components with support for one-way data binding by parameter passing. Any other updates are by event notifications, as the commenter said.

Ah thanks for clarifying, it sounded like you wouldn't recommend either Lit or Stencil.

Re: Why I don't miss React: a story about using the platform

#250
post #249

Earlier quoted context omitted.

In Lit, yes. It's hand-crafted web components with support for one-way data binding by parameter passing. Any other updates are by event notifications, as the commenter said.

Ah thanks for clarifying, it sounded like you wouldn't recommend either Lit or Stencil.

Sorry if I wasn't clear. I'm a huge fan of Lit! It gives you the freedom to make your own framework -- the parts you need. I respect the OP's comment and our difference of opinion, which is why I didn't reply negatively to it.
Post reply on HN