News for hackers. Stuff that matters.
Re:Introducing Hooks by eric_b on Thursday October 25, 2018 @03:00PM (#18303585)
There are a lot of gotchas with these. Don't call in conditionals, branches, loops. Can only be called from function components. Order of invocation matters (yeck!)

If the goal is helping developers "fall in to the pit of success" I think classes are a much better option than this.

Re:Introducing Hooks by lacker on Thursday October 25, 2018 @03:18PM (#18303726)
There are a lot of gotchas with the object-oriented way of doing these things too. Don't set `this.state` directly, don't forget to keep your side effect logic in `componentWillMount` parallel to your cleanup logic in `componentWillUnmount`, et cetera.
Re:Introducing Hooks by eric_b on Thursday October 25, 2018 @03:33PM (#18303871)
Yep, no doubt. The problem is they aren't getting rid of old foot guns, just adding new ones. And the new way with hooks isn't obviously superior to the old way (debatable to be sure, but with all the constraints hooks are not a broadly applicable solution to many problems). So now you've got two separate but equally powerful guns pointed at your feet.

Is that progress? I'm too old to think so.

Re:Introducing Hooks by k__ on Thursday October 25, 2018 @03:30PM (#18303845)
Inl don't understand why they don't use a second parameter to mark the calls.
Re:Introducing Hooks by ec109685 on Friday October 26, 2018 @01:00AM (#18306887)
If you don’t put this in conditional, branches or loops, by definition they will always be called in the same order.
Re:Introducing Hooks by nyclowkey on Thursday October 25, 2018 @03:07PM (#18303631)
yep I see nothing wrong with classes, infact I think I'm going to go back to an older build of React. All this suspense, the messy fiber rewrite and all is just screwing up library.

LONG LIVE class based component, there was nothing wrong with them. Don't fix it if ain't broke.

Re:Introducing Hooks by scrollaway on Thursday October 25, 2018 @03:20PM (#18303740)
Good thing then that, as the page says, "There are no plans to remove classes from React.".
Re:Introducing Hooks by hajile on Thursday October 25, 2018 @05:05PM (#18304581)
If an older version of react is the goal, maybe infernoJS would be the ticket. It's way more performant than most versions of React while being mostly API compatible (not sure about the most recent react changes).