Skip to content

Instantly share code, notes, and snippets.

Last active Jan 23, 2017
What would you like to do?
import {connect} from 'react-redux';
function connector(mapStateToProps, mapDispatchToProps, composes, component) {
const conn = connect(mapStateToProps, mapDispatchToProps);
return conn(composes.reduce((a, b) => b(a(component))));
Copy link

renanvalentin commented Jan 23, 2017

I would suggest to change to something more declarative. Like a reduce instead of a for..of loop. Plus I don't think we should wrapp the connect method, rather we could enhance the component

connect(mapState, mapDispatch)(enhance(Component, [1..n]));

or using decorators.

What about those scenarios that we pass a second argument?
Compose([1..n], doSomething())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment