DEV Community

loading...

Discussion on: I prefer Reducer hook over State hook, here's why

Collapse
blueboy6 profile image
BlueBoy6

Well.. i agree that useReducer is a wonderful hook but we can't compare him to useState because theirs uses are differents.
When you're designing your app on atomic design pattern, and you want to give a local statement controller to button or input it's preferable to use a useState hook with handler function who treat the event. It's more readable and clear.
useReducer is more appropriate to be used on app's global statement (with API context for example) or on component's group. To give you a simple example, you don't gonna use redux just to control a checkbox statement, right ?

However it's nice article ;)

Collapse
kojiadrianojr profile image
JARVUC Author • Edited

I super agree! Thank you so much for your input.

To decide what to use between State and Reducer Hook, we need first ask ourselves how complex and big the job is gonna be.

I won't use redux for handling a checkbox statement. As you said, which I totally agree.