DEV Community

loading...

Discussion on: useReducer instead of useState while calling APIs!

Collapse
bpitts8019 profile image
Bradley Pitts

While it is possible to use more than one useReducer for the state of a component. I would recommend against it as each use of the useReducer hook will return it's own state object and dispatcher. Instead design the single reducer to control the whole state of the component. Any defined action in the reducer should return the whole state of the component with any expected updates as per that defined action.

Collapse
jharteaga profile image
Jose Arteaga

Very clear your explanation Bradley, got it! Thanks so much!

Some comments have been hidden by the post's author - find out more

Forem Open with the Forem app