4 ms·
They're low-level interfaces to a custom property and method lookup table in a language that already has that built-in. I guess it might just be me but I get a
by spanhandler 6y ago
They're low-level interfaces to a custom property and method lookup table in a language that already has that built-in. I guess it might just be me but I get a little chuckle every time I read/read-praise-about/use them.
I dunno, the functions-or-bust crowd happily doing and championing manual OO machinery fiddling amuses me.
- SketchySeaBeast 6y agoDoes that built-in method lookup table contain all the re-rendering and general state management work that React does with its hook?
- spanhandler 6y agoNah, but that could have been build on traditional methods and properties just as well, without having to re-implement those first. It's not like every component doesn't resolve to an instance of an object anyway. [EDIT] what they couldn't have done, probably, would have been cleanly implementing that on top of class-based components without then having to tell their large and influential functions-are-the-only-way constituency that they'd need to write a lot more classes in the future. I suspect aversion to having to deliver that message is part of why we ended up with hooks as the solution, and classes left behind instead.
- SketchySeaBeast 6y agoI can understand why it may seem non-optimal, but I don't have much of a dog in the fight, and I refactored a hobby project to react hooks a little while ago and found it both much less code and much less complicated. But to each their own.
- dragonwriter 6y ago> what they couldn't have done, probably, would have been cleanly implementing that on top of class-based components without then having to tell their large and influential functions-are-the-only-way constituency that they'd need to write a lot more classes in the future. They were saying that for a long time before hooks when the only way they had it implemented at all was for classes, and functional components were usable for much narrower use cases. I suppose, if they could have done it cleanly with classes, they would have, whatever that meant saying to those downstream who aesthetically preferred functions. I don't know if it inherently worked better with functions, if the core devs themselves are just more proficient in that style, or if it was just a confluence of experience and the timing that the push to improve functional components occurred, but in the end functional components are just much cleaner.