Decoupling React Components and Redux Connect

Posted by Andre Scott | Updated on

Decoupling React Components and Redux Connect. In redux, exist a new kind of component that is called containers, this is the component that use connect(mapStateToProps, mapActionsToProps), to pass the state and actions to the current component.

All depends of the use of the component. For example, if you component Search only going to be use with the same state and action, You container could be the same that your component like this:

But if your plan is reuse this component in another containers and the searchTerm or the action are different on the global state. The best way is passing this properties through other containers, and keep the Search component pure. Like this:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers