Skip to content

Instantly share code, notes, and snippets.

@rougeth
Last active Jan 23, 2017
Embed
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))));
}
@renanvalentin
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