This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would suggest to change to something more declarative. Like a
reduce
instead of afor..of
loop. Plus I don't think we should wrapp the connect method, rather we could enhance the componentconnect(mapState, mapDispatch)(enhance(Component, [1..n]));
or using decorators.
What about those scenarios that we pass a second argument?
Compose([1..n], doSomething())