DEV Community

Discussion on: You might be overusing React states

Collapse
 
dionarodrigues profile image
Diona Rodrigues

Hey, could you explain it? How useReducer() can replace states?

Collapse
 
amoghtelkar profile image
amoghtelkar • Edited

You need to create a useReducer inside the component , you need to pass reducer and initial state to it. This will act as reducer for that component as we defining and declaring inside it. It acts as a store only for that component.
This will reduce the multiple declarations of useState.