Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to store in redux state?

Tags:

reactjs

redux

I'm building a medium-sized React/Redux app, and I've become very comfortable with React - however, Redux is still a little hard to wrap my head around.

I understand that I can use connect() from Redux to connect any Component or Container to Redux state. However, I'm unclear on when to do this - is it based on complexity? How many props would need to be passed down to child components?

What are the factors I can use to determine when to use connect()?

Edit to provide an example: -----

For example, I'd like to include a messages area for users inside my app, particularly a badge showing number of unread messages. Would I simply connect() any component where I'd like to display the badge?

like image 828
Toby Avatar asked Jul 22 '16 00:07

Toby


1 Answers

I DON'T agree about storing all component state in the store. I prefer having in the redux store only data that matters to application as a whole and thus other components may benefit from this global accessible shared data.

Having component specific state in the store, that only matters to this component, is a overkill and useless IMO.

like image 141
dferrazm Avatar answered Jan 25 '23 20:01

dferrazm