Sharing state between Redux reducers

When writing an app using Redux and React, you may run into the common problem of having to share state between multiple components in your app.

Don’t worry, you aren’t the first to have this problem, here are some resources to help you out.

Your options:

  • don’t use combineReducers (write your own that shares state/selector between two components)
  • use thunk middleware
  • pass selectors on global store through all your actions
  • call window.store.getState().myreducer.myvalue directly to get the state (worst option)

On Managing state hierarchy in general:

Specifically on sharing state between reducers:

Related Documentation:

Advertisements

2 thoughts on “Sharing state between Redux reducers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s