Dilemmas with React Hooks – Part 1: States and Reducers
On the other side, instead of using useReducer, we could just create a named function for each scenario of the setter of useState and achieve the same goals, but useReducer is a central place that can solve all our problems, and I will show more advantages of it on the next section. Every time we render the ColorsApp component, the callbacks functions are recreated, so their reference is different from the last render and the shallow equal check returns false. When I write “reducer” I mean the first parameter of the useReducer hook, the function which gets a state and action and returns the updated state.
Source: yearn2learn.netlify.com