Deciding between useState or useReducer in React

Blog post by Kent C Dodds about useState/useReducer

Whenever there are two things to do the same thing, people inevitably ask: “When do I use one over the other?” There are two possible reasons for having multiple ways of doing the same thing:

One is the “old way” and the other is the “new (and improved) way”. Typically the old way is kept around for backward compatibility reasons and the new way is the path forward for new code. For example: class components (old way) vs function components (new way).

They come with different trade-offs that should be considered and therefore should be applied in situations that suit them better (sometimes meaning you’ll use more than one in a given application). For example: useEffect vs useLayoutEffect or Static vs Unit vs Integration vs E2E tests or “Control Props” vs “State Reducers”

useState and useReducer fall into the second category here. So let’s talk about the trade-offs.