What is the useReducer hook and when would you prefer it over useState?

React Developer Medium

React Developer — Medium

What is the useReducer hook and when would you prefer it over useState?

Key points

  • useReducer is ideal for complex state logic
  • It utilizes a dispatch-action pattern
  • Next state depends on multiple sub-values
  • Not limited to primitive values only

Ready to go further?

Related questions