...

/

React Hook with Reducer Pattern

React Hook with Reducer Pattern

Learn how the “useReducer” hook helps manage state with React Hooks. The lesson will also cover use cases and example usage.

We'll cover the following...

What is it?

useReducer hook is an alternative to useState. It offers more control on the next state value based on a given action.

If you are familiar with Redux Reducers, useReducer hook provides similar functionality out of the box in React.

When do we use it?

useReducer can be used in the following scenarios:

  • The shape of state object is complex. Maintain multiple items within the same state object.
  • Access previous state value to update the next state.
  • Apply special logic on certain actions
...