News for hackers. Stuff that matters.
Re:React I love you, but you're bringing me down by ajkjk on Tuesday September 20, 2022 @12:54PM (#32914510)
Heh. Arguably JS itself "invented a half-baked, partial re-implementation of objects/classes"... _in their class implementation_.

God it drives me nuts that the language will allow you to spread a class into an object and it will take the properties but not the methods.

Re:React I love you, but you're bringing me down by yamtaddle on Tuesday September 20, 2022 @12:59PM (#32914599)
Oh, absolutely. Pretty much every distinctive feature of prototypal OO is best classed as "please, never ever actually use this". Adding the "class" sugar and general agreement to pretend the prototypal stuff isn't there, though, made JS OO usable-enough. But yeah, it's not great.
Re:React I love you, but you're bringing me down by H1Supreme on Tuesday September 20, 2022 @01:44PM (#32915181)
Exactly! If the Javascript implementation was better, React probably never would have had to come up with Hooks in the first place.
Re:React I love you, but you're bringing me down by imbnwa on Tuesday September 20, 2022 @03:01PM (#32916316)
You can solve the problem Hooks purported to solve in plain, idiomatic JavaScript with classes[0]

[0]https://raganwald.com/2016/07/20/prefer-composition-to-inher...

Re:React I love you, but you're bringing me down by ajkjk on Tuesday September 20, 2022 @03:35PM (#32916701)
This thread may have an OP who prefers classes, but I'm for one 100% in favor of hooks. You could struggle and suffer to solve them with classes, or you could move on to something better.