DEV Community

Discussion on: You don't need useReducer

p0oker profile image
Pooria A

Well this pattern works well for a simple object like yours. If it's a deeply nested object and for any reason you need to keep the integrity of the object, reducer composition is something that would add lots of value to you.

adamklein profile image
adam klein Author

Can you give an example?
If I understand you correctly, then you can also compose the setter function of useState and add functionality on top like data integrity.