React Bindings for Redux

When you use Redux, your component can dispatch an Action and pass the initial state.

Now this Action will cause the state to change, but how does your component know about this change, for React to update the UI after state change? For this you may either have the dispatcher return the new state to the component.

This works except if there is some other component that uses the same slice of the store. Who will tell it that the state has changed and provide the new state to it?

For this there is a library called react-redux . You use this lib to map your component’s props with the slice of the store that they’re bound to. Now whenever that slice changes, the lib will update your props.

React then sees the props have changed and updates the UI. Simple.

Except that it’s simpler with Angular 2 where the ngrx-store is an observable and so components observe slices of the store and are automatically notified of the change, hence eliminating the need for an external library to manage this.

Advertisements

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