This kind of automatic optimization was one of the reasons they pushed for function-based components ~6 years ago over class-based components. One of the main points was "you'll no longer need to think about shouldComponentUpdate()".
This kind of automatic optimization was one of the reasons they pushed for function-based components ~6 years ago over class-based components. One of the main points was "you'll no longer need to think about shouldComponentUpdate()".
I quite regularly find myself looking over the fence as it were and genuinely can’t believe people would willingly work like that with the insane levels of complexity and nonsense that the React ecosystem has become in recent years.
Looks vaguely like Stockholm Syndrome from the outside
I find that hooks are fine when you want to do simple web-app stuff, like fetch from a db, post some data back. But once your effects get more complicated, like using web sockets, items with retries, play or queue async audio clips that have to be state managed with hooks—the house of cards comes crashing down and they are an absolute nightmare to work with.
They're such an anti-pattern that useRef has to be repurposed from a thing that was meant for holding a reference to an HTML element to a new thing that is used to hold state that doesn't trigger a lifecycle update—and there are many paradigms that you can find yourself in where the only path forward is to use refs, along side and inside of your otherwise lifecycle updated hooks. What kind of cluster f*#& is that.
But all the manual dependency tracking is a real hassle and is crying out for language-level support, to which this compiler brings us a step closer.
Hooks do seem to be gaining some traction in Flutter, FWIW.
And I wouldn't write complex modern applications in anything else, unless there's computationally heavy rendering going on. And even then, I would still try to keep other parts, like slower and not as expensive to render UI, in this paradigm.
I honestly can’t believe everyone willingly marched into this weird hooks land. I’m sure you get used to it but compared to other frameworks it’s such a chore. The more I use React the more I feel like the maintainers deliberately make it different from other stuff so that people get trained in “React” rather than “JS” and it becomes its own world.