DEV Community

Discussion on: Wisely Designing your React Components

Collapse
 
ngamsomset profile image
Brian Ngamsom

According to the React Doc the useReducer is prefer over useState if you have a complex state logic or your next state depends on the previous one. The latter case is pagination.

Collapse
 
finkrer profile image
Evgeny Zyrianov

Unfortunately this is not a good example of using a reducer. It could work for pagination, but you would place the next/previous/set logic inside of the reducer. In this case it's essentially used as useState.