Live data from Hacker News

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

jackfranklin.co.uk

231–240 of 279 posts

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

#231
post #198

Earlier quoted context omitted.

Would love to know what the app does. From the mentions of xpath all I can think is "visual xml editor"?

ideas: could be using data returned in XML format because there is no JSON endpoint for that particular data source. XPath is also nice for dealing with just about any complex markup tree, for example if you needed to extract data from serialized DOMs that were sent to your application somehow. How about SVG tools using XPath?

Thanks, great ideas and I'd never considered XPath for SVG. I need to delve into that one further.

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

#232

Earlier quoted context omitted.

React doesn’t offer any render optimizations by default, so not worrying about it sounds like blissful ignorance - you’re just ignoring a ton of unnecessary renders because they don’t visibly affect performance (on your development device). After a certain level of complexity the issues will start to show.

React offers tons of optimizations for not re-rendering. useEffect, useMemo, useCallback.

"by default". You still have to use those manually.

One of the promises of switching from class-based components to function-based was supposed to be an automatically applied version of shouldComponentUpdate, which AFAIK was never fulfilled.

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

#233
post #11

> But the web platform isn't perfect, and I suspect most React developers have come across a situation where you’d love to be able to just tweak how your component is being rendered. Honestly, I haven't. The only potential caveat I can think of is when you have some non-reactive legacy code you want to embed inside a React component... but even then React's escape hatches are more than sufficient. If you're really wo…

I take your point, and can appreciate how more familiarly will lead to greater ability to address these sorts of things, but I do feel like your last two paragraphs / “caveats” could represent a massive edge case.

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

#234

Earlier quoted context omitted.

This is categorically false. If you want to update props in a stateful component it is exactly the same - just pass new props. If you instead are talking about syncing props with state, there are ways to do this as well without changing the key, but this is considered an anti-pattern in the first place. This sounds more like bashing react without even knowing it very well in the first place.

If you pass new props, it swaps out the whole instance of the element in the document. Probably.

But it doesn't do this is my whole point. React will not blow away the entire DOM in the document even if props change.

It will correctly keep your scroll position, caret position, etc. if you use React the way it's intended to be used, which is very easy to do and learn. Of course if you use the `key` prop to blow away the entire DOM with every change all these benefits are lost, but thats not react's fault, its your own.

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

#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?

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

#237
post #91

Earlier quoted context omitted.

I've come to the conclusion that web components (with or without shadow roots) are not the best "elementary particle" to build a webapp out of. Most of the time you want simple divs and sometimes you want custom-tag. The important thing is to have a setup where you can quickly promote a component into a web component proper. I think solid.js has a nice solution this, where you just call a function that wraps the comp…

What's the threshold for you, where something needs to be a web component? Honestly I just like the idea of making my own HTML tags and being able to do more with markup.

Only web components if you don't control the rest of the page, like someone embedding your component on their page, but I would still give them the control to name the component. That is a lot of work just so you can write my-tag instead of .className in your css file. I think the react way of styling each component inline is the way to go.

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

#238
post #174
post #126

Earlier quoted context omitted.

Just a friendly reminder that React is approaching a decade in life. There are no other competing frameworks that look to be taking it’s place. Not saying it will never go away, just that, maybe the front-end world has finally, significantly slowed down in churn. Things could always be better (Svelte is nice) but overall, React does what I need and I rarely curse at its design.

How was the situation of jQuery 2014? Seems to me pretty similar. So in 2030, react will still be widely used but largely obsolete.

Not at all.

From jQuery’s release to 2014 there were multiple phases of front-end frameworks.

Backbone, Knockout, AngularJS, Ember. All of these had their time in the light during that phase. Most companies were already switched over to one of these frameworks. React was the new kid on the block at this time.

You Don’t Need jQuery was out well before 2014.

It’s also a bit difficult to compare jQuery since it’s a library that can linger in a codebase indefinitely. It’s not a framework.

Also jQuery release date was 2006, so the equivalent year 9 would be 2015. By which point React migrations were in full swing. I wrote my first on the job React + Flux application in 2014 and then joined a new larger company in 2015 where we were making plans for a React migration.

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

#239
It's so strange to me how not using a framework is so often displayed as the "simple" solution. Not using a framework basically means using global, mutable state. This is maybe ok if all you need is one or two dropdowns. But anything further it isnt the way.

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

#240
post #56

Earlier quoted context omitted.

If you're using a framework like lit-html as the author recommends, it will replace the string every update. Most people will prefer that way since it's more ergonomic and similar to React. You could do imperative DOM updates, but that'd be like going back in time to jQuery.

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/packages/lit-html/src/l...

[2] https://github.com/lit/lit/blob/main/packages/lit-html/src/l... and https://github.com/lit/lit/blob/main/packages/lit-html/src/l... and so on.

[3] https://github.com/lit/lit/blob/main/packages/lit-html/src/l...

Post reply on HN