It’s not complicated at all.
It’s not complicated at all.
If your large, complex, react app is slow - what is easier? Fixing the data architecture or adding a useMemo? Multiply by that by 1000 and you have a nightmare. The bad thing/escape hatch is vastly simpler than the proper thing, because something about language/framework/api makes doing the proper thing hard or unclear.
The language is sort of settled. The browser runs JS, so for most projects, it's the right choice.
> If your large, complex, react app is slow - what is easier? Fixing the data architecture or adding a useMemo?
It might be easy to add useMemo, but it doesn't work. People using a tool for the wrong thing because they don't understand it isn't a problem with the tool. It's unfortunate that a tool with a steep learning curve is the "default" for many devs now, but again that isn't a problem with the tool. I don't have any guardrails keeping me from using my saw as a hammer, it just doesn't work.
> because something about language/framework/api makes doing the proper thing hard or unclear.
It's unclear because it was built on functional programming concepts and most devs aren't taught that way. If you are familiar with those concepts, the whole thing is quite simple.
If the tool is easily misused, the tool is wrong. i.e. "You're holding it wrong" is a problem with the phone, not the user.
>The language is sort of settled. The browser runs JS, so for most projects, it's the right choice.
TypeScript exists. Something could be made that compiles to JS that makes this easier.
There are more opinionated UI frameworks (angular) and frameworks with less magic baked into them (svelte, solid). React gives you the freedom to architect your app the way you want, for better or for worse. It was made by functional programmers to allow them to use composition and other FP paradigms in UI development. If you don't understand those concepts, or you just don't care for them, you're going to be swimming against the tide. Lots of tooling has been created to help those who do (Redux, for example).
Maybe you're right and "you're holding it wrong" isn't a valid answer, but it's not React's fault it took over the world. It was made to do a certain thing, and it's pretty good for that. That thing requires a way to create side effects (useEffect) and a way to provide referential stability (useMemo, useCallback). The React team has done a lot to document the right way to use these tools.
If it's not someone's thing, that's cool. If they are forced to use it at work, might as well learn a little FP and make life simpler.
It’s quite easy. The complaints people have about it are due to friction from using it wrong.
And keeps in mind, react hook until 18 (a long time since hook introduced) didn't offer a official way to connect component to external changing data. The only way you can do is by using useEffect incorrectly.
You mean correctly. That’s was what it was for. Syncing with external systems.