DEV Community

Discussion on: 3 Tips to write better react components

Collapse
 
elisealcala profile image
Elizabeth Alcalá

Hi, I don't know if it looks like but I'm not familiar with Redux, I think I used it just two times in my two years working as a developer.

I know what you mean when you said that you can't look at the difference in those examples, but I didn't mean that useState code just look ugly and useReducer is better, it's just that for this component, in particular, having multiple setState just didn't work. It's not maintainable.

And this doesn't mean that I'm going to use useReducer for all my components. I'm using useState 90% of the time, and that will not change, but when you have a complicated state, you may need a reducer.
Adding actions can increase your vision of what's happening with all your states. But also you can have a very clean and readable code with just using setState.

Collapse
 
bytebodger profile image
Adam Nathaniel Davis

Ahh, very interesting. Thank you for the reply (and I agree with you).