Mine is that the useState hook is an actual plague on the entire React ecosystem. Regardless of your opinions of React, if you wanna use something then use it right.

  • danhab99@programming.devOP
    link
    fedilink
    arrow-up
    2
    ·
    16 hours ago

    A bunch of weeks ago the CTO of my company calls me up to ask about my prejudice against the useState hook, I’m guessing I’ve just been giving my team too much shit in code reviews about them using useState hooks and they went to complain to him and he asked me to explain what the value of the useReducer hook was.

    His background is Java, Microsoft Java, C++, and not much else.

    So I was able to explain to him the value of the useReducer hook is a lot like the common class object. In useReducer you’re expected to write discreet state mutations and the state could potentially have more than 1 primitive field that gets mutated, and that’s just what object classes are! In an object class you’re writing methods for mutating the underlying state, the reason I think most people don’t feel like these two things are the same is because of the functional appearance of the reducer function and how in object classes you have the this as a variable just like any other, so you’re not returning a new state.

    So just like in react where they’re installing REDUX (like three generations of their families would be massacred if they didn’t) just to write a switch case statement that puts the action in variables in the state. Bad programmers are just bad.