Live data from Hacker News

React is holding me hostage

emnudge.dev

431–440 of 553 posts

Re: React is holding me hostage

#431

Earlier quoted context omitted.

> the modern webapp experience is so miserable for the average person. I see this claim a lot and I'm curious what this is based on, can somebody drop some links to further reading?

Same. We've been working on a huge React project for several years. Lots of graphs, 3d models etc ... and it is super-snappy. Only slow part is a WebGL-based chart component that visualizes 2-3 M rows of signal data. We can probably decimate the signal data to improve performance, but that has got nothing to do with us using React. N.B. No one is using the app from their mobiles. iPad and computers only. Our reasons…

Modularization. With React, you can delegate a component to one team and use it as a web-component.

Actually, why aren’t web-components a thing, that’s another story. But componentization is why React creates clean code.

Re: React is holding me hostage

#432

I never understood why React became so popular. I thought it was a kind of mass hysteria. I was exposed to a broad range of front end frameworks early in my career (Backbone, SproutCore, JavaScriptMVC/CanJS, AngularJS), one of my colleagues was experimenting with Google's PolymerJS and recommended it. After trying it out, I was blown away by its elegance and simplicity. Yet somehow it never caught on. When React came…

Love to see the Polymer shoutout - Lit, the web component library produced by the Polymer Project, is still my favorite way to organize web components. Nice and simple, provides just enough tools to be useful but mostly stays out of your way, and mostly sticks close to the metal on native web components.

I’ve always thought React was some sort of mass hysteria as well.

Re: React is holding me hostage

#433

I'm still a React guy. I've also worked with Angular and Vue and toyed with Svelte. People tend to compare these frameworks on things that don't matter - often it's performance. We used to compare React performance to AngularJs performance too, which was meaningless. VDom is nice. Reactivity in signals is nice. Limiting rerenders is nice. But I choose frameworks because of developer ergonomics. The killer feature for…

There's 2 things that I hate about react. 1) JSX - It's terrible. Svelte, Vue, Riot... they all got it right. JSX, mixing a weird syntax of HTML and JS together is just inferior to HTML with additional markup. 2) I don't know why but every react project has crazy levels of abstraction. Everything is 15 layers deep and making any sort of change requires way too much effort to navigate 15 files and code reading to make…

I absolutely love JSX. I came from a templating framework (marionette) and writing in JSX is amazing compared to that.

Re: React is holding me hostage

#434

Earlier quoted context omitted.

How is performance not important in this context? React is very sluggish when updating many elements at once, for not very large values of "many". With some regularity, I've debugged React+MobX jank issues where a bigger update, such as switching from one panel to another, takes upwards of 200ms on a mid- or low-range machine. None of this is perceptible on our beefy dev boxes, which is why I think people disregard i…

"the modern webapp experience is so miserable for the average person." Hyperbole. Web apps would not be so ubiquitous and popular for solving business problems if your claim was true.

The gulf between "showing up in person and waiting in line at the bank" and "performant web app" covers a lot of ground, most of it shitty and frustrating, and that easily can be many times better than it currently is.

But yeah, I guess you're not waiting in line at the bank anymore.

Re: React is holding me hostage

#435

Earlier quoted context omitted.

Glad to hear RTK is working well for you! FWIW, we actually specifically recommend _against_ using sagas in almost all cases. Instead, we recommend using our RTK Query API for data fetching and caching, and the RTK "listener" middleware for reactive logic: - https://redux.js.org/usage/side-effects-approaches#recommend...

Thanks, I wasn't aware RTK now has a saga-like "listener" feature - will look into it! What I like about sagas are their simplicity & power (once one understands how generators & effects work), plus the eventChannel feature which lets one integrate with non-redux events. Good TypeScript support is a problem though, and I've had to resort to typed-redux-saga :/

Yeah, we specifically designed the listener middleware to do ~90% of what you could do in sagas, but with a smaller bundle size, simpler API, and better TS support:

- https://redux-toolkit.js.org/api/createListenerMiddleware

- https://blog.isquaredsoftware.com/2022/03/designing-rtk-list...

Event channels was something we intentionally _didn't_ try to replicate per se, and tbh I've never tried to use those myself. (But, I _suspect_ that you might be able to do something similar with listeners even though we don't have a specific replacement built into the listener middleware, and if you do I'd love to see an example in action!)

If you get a chance to try out listeners in your project, I'd definitely appreciate feedback on how well they work out for you - whether they solve your current saga use cases, what cases they _don't_ handle, anything we can do to improve the listener API, etc.

Re: React is holding me hostage

#436
post #27

I've been working on a React side project for a few months now and looking at my company's apps plus posts like this I think people just miss the point. Stuff like this: >Things get more complicated when you start using React Context and start signalling updates in a parent component. The render cascades. Maybe one component fetches some data, some component remounts, and you run your state update again, delayed by a…

The bit of react that is f ( newState ) => UI is the easy part. The bit that is g ( state , userInput ) => newState is the hard part. In particular managing the scope of that newState . Oh, and sometimes you need to handle h ( state , asynchronousData ) => newState too. And then comes the fact that even though your f is _pure_, it also has to be _fast_, because it's going to run every time you get a newState .

> because it's going to run every time you get a newState.

Didn't have to in the past. Back with class-based components we had shouldComponentUpdate(), and lost that when components switched to pure functions.

Re: React is holding me hostage

#437
post #81

> It is not obvious that your component re-renders on state updates. I... isn't it? Isn't this like the first thing in the hooks introductory material? If you don't find this, yeah, hooks are gonna be a bad time.

I went and checked, and it is a bit buried at the bottom of the useState explanation when explaining what an example does: > Line 9: When the user clicks, we call setCount with a new value. React will then re-render the Example component, passing the new count value to it. https://reactjs.org/docs/hooks-state.html I think they assume you'll figure out that it must do so to function at all.

I had a co-worker that assumed it worked template-style, where the value in the JSX would update and what's on the page would re-render, but the component function wouldn't be re-run.

Re: React is holding me hostage

#438

Earlier quoted context omitted.

"Doesn't reinvent the wheel" they literally created a whole new language called JSX, I have 13 years writing JS and I dislike React and JSX is one of the reasons. As far I can tell reason it's picked a lot of times now it's market share, people see that is more popular than the competition so they try to learn it, creating a feedback loop that just makes it more popular.

I actually like JSX a lot, but I'm baffled when people act like the very thin DSL used by svelte is any more unapproachable than JSX, or like JSX is somehow more javascript when it's a mish-mash of extended HTML (don't forget to use key as needed, and className), React components, and JS (expressions only, not statements... and weird-looking ones at that)

JSX is a simple transformation of nested JavaScript functions, but the custom DSLs used by other frameworks is string templating, which is kind of an inversion of how JSX works. JSX also has extremely good support in just about every editor and it supports TypeScript, which is not true of every DSL.

Re: React is holding me hostage

#440

Earlier quoted context omitted.

Well, don't use those. Pure React is enough 95% of the time, and then an additional 4.9% can be handled with jotai in a couple of places. React + GraphQL + jotai is my preferred stack

> Don't use those...then an additional 4.9% can be handled with jotai... Needing Jotai on top of React's defacto state management is the issue. TFA talks about an ecosystem of libraries that attempt to fix React's shortcomings. Pure React does have undeniable shortcomings like proper, non-brittle routing.

Jotai is literally like a single file.

Here's a video on how to use Jotai by writing your own in minutes: https://youtu.be/gg31JTZmFUw

Post reply on HN