DEV Community

Discussion on: Connect useEffect and useState to Update Components with Data

Collapse
 
thorocaine profile image
Jonathan Peel

How do you feel about putting {index, pokemon} into a reducer, so you only have one "state" object?

Do you think it is too much here because they always update independently?

Collapse
 
chantastic profile image
chantastic

great question!

You could go either way, depending on your comfort with reducers.

I think the end result would impact my preference.
For example, I don't like having two pieces of state in a reducer that control the same outcome — index and pokemon.

I think it'd depend a lot of the final component whether I kept index or pokemon in the reducer.

I'll try to flesh that out a little more in the later lessons.

Thanks for asking!