this post was submitted on 25 Oct 2026
371 points (95.1% liked)

Programmer Humor

33844 readers
1457 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS
 

Mine is that the useState hook is an actual plague on the entire React ecosystem. Regardless of your opinions of React, if you wanna use something then use it right.

you are viewing a single comment's thread
view the rest of the comments
[–] jonathan7luke@lemmy.zip 24 points 3 days ago (1 children)

Care to elaborate on this? Not saying you're wrong necessarily, that's just a pretty bold claim and I'm curious why.

[–] danhab99@programming.dev 30 points 3 days ago (4 children)

React works by maintaining a virtual representation of the DOM. When you dispatch state changes into the virtual DOM react can determine which components depend on the change and which side useEffects run.

My gripe is that YouTube tutorials teach that the useState is the equivalent of a variable. This encourages average developers to problem solve solutions that end up using React's Virtual DOM for business logic. The YouTube tutorials have react devs planting 100s of useStates - some of which don't directly induce a visible-on-screen rerender - and then ⅒ as many useEffects to bind these states together. This means that for the Virtual DOM to come to the conclusion as to what html elements need to be changed and how it has already mutated 20-50-100s of times and the CTO tells me the react app is slow and they're mad.

If 2 states have the opportunity to mutate each other back and forth then the truth is that you have 2 perspectives of the same state. And React gives you solutions for that - proper solutions - the useReducer hook is for defining these complex state mutations and the Context API for communicating that state to any component.

And this has me quintuple pissed off because these same tutorial grade react devs install REDUX as compulsively as a pack-a-day smoker (that's #3). They use Redux to file variables in JavaScript memory (that's #4) like it's a global variable and rarely if ever use it for the complex state mutations they need instead I've seen react devs write components pull state out of redux into a component just so it can mount useEffect and process the state and dispatch the result back into redux. Let's not even bring up how the react-redux binding library literally uses the React Context API (that's #5).

[–] Cratermaker@discuss.tchncs.de 26 points 3 days ago (2 children)

As someone who's worked with react for years, I'm convinced that react itself is the problem and there's no way to educate new people on the proper way to use it without essentially teaching them everything the abstraction is intended to do for them. Why should newbs have to care about mutations and state dependencies when the api is apparently designed to help them forget about those things?

[–] shoo@lemmy.world 8 points 3 days ago

Exactly this. Instead of learning about the complexity and footguns of working directly on the DOM, people get to learn about the complexity and footguns of manipulating the virtual DOM.

React isn't bad, but it was designed in a very opinionated way to build certain kinds of apps. Excessive abuse of React hooks shows a common desire path to build things that don't require that framework. Most people basically just want signal based reactivity but don't know that it exists.

[–] FooBarrington@lemmy.world 2 points 3 days ago

The React devs fucked up by not wrapping state in trackable containers, and we're all paying the price with laggy apps.

[–] jtrek@startrek.website 13 points 3 days ago

As a tutorial grade react developer (please return me to the backend where I am mediocre instead of bad), having more senior developers take the time to explain why my code was bad was really helpful.

Also I think I just kind of hate JavaScript. It always feels like everything is more complicated and booby trapped than it should be.

[–] kionay@lemmy.world 6 points 3 days ago

Since it's apparent you can spot what tutorials do it wrong, would you be able to provide links or references to online tutorials that get it right?

One of the most valuable things you can do if you know a technology well enough to have these gripes is not just to condemn people fucking it up but shine a light on people that are trying to do it well.

[–] orca@orcas.enjoying.yachts 1 points 3 days ago

I’m suddenly reminded as to why I went Vue years ago and never looked back lol.