The purpose of useReducer hook is similar to the useState hook. Both are used for updating the state of some value.
One major advantage of using the useReducer hook is, as the name suggests, to reduce the amount of code in a single callback function by dividing different actions using different functions.
For useState, we create one like this: