News for hackers. Stuff that matters.
Re:Understanding UseMemo and UseCallback by jameshart on Tuesday August 30, 2022 @05:20PM (#32655238)
I wish people would stop saying this. Hooks aren’t functional or stateless.

Literally, calling ‘useMemo’ twice returns two different objects, because the function keeps track in internal state of how many times it has been called.

Hooks are very deeply imperative.

They are a way of obtaining some benefits that are easily obtained in functional programming via higher-order functions, but expressed in a way that makes them easily consumed in an imperative code body.

Re:Understanding UseMemo and UseCallback by jefb on Tuesday August 30, 2022 @05:42PM (#32655519)
Hooks are obviously not stateless - I'm saying they were an inevitable consequence of the push towards functional components and that they represent an inferior development experience. No one needed to write 2000 words on how to use setState.
Re:Understanding UseMemo and UseCallback by johnfn on Tuesday August 30, 2022 @08:55PM (#32657093)
Couldn't disagree more. Do you remember all the nonsense you had to read about componentWillUpdate, componentDidUpdate, getDerivedStateFromProps, componentWillMount, componentWillUnmount? What a mess. Hooks clean up so much of that complexity.
Re:Understanding UseMemo and UseCallback by bezier-curve on Wednesday August 31, 2022 @04:10AM (#32659626)
Maybe this has more to do with how people look at these paradigms. I find the class based lifecycle methods much easier to wrap my head around than hooks. I think hooks are more of an answer to higher order components. They make sense to me when I look at them that way, but as a replacement for classes, function components seem inferior from a maintainability perspective.
Re:Understanding UseMemo and UseCallback by eurasiantiger on Tuesday August 30, 2022 @05:31PM (#32655384)
That is all sorts of funny for people who remember PureComponent and all the hype about functional components.

React has always been an exercise in smoke and mirrors.