sajad torkamani

Consider using useReducer when you have multiple state pieces that often change together or when updating one state depends on reading the value of another state.

A reducer helps centralize how multiple related state slices are updated in response to user actions or events which usually makes your UI easier to reason about.