hoc-compose
v1.0.2
Published
Compose multiple higher-order components with easy to read single function compose()
Downloads
76
Readme
Single compose()
function, taken from Andrew Clark's recompose library.
const composedHoc = compose(hoc1, hoc2, hoc3)
// Same as
const composedHoc = BaseComponent => hoc1(hoc2(hoc3(BaseComponent)))
Install:
npm i -s hoc-compose
Example usage:
import { compose } from 'hoc-compose'
// ... your code
export default compose(
withRouter,
withApi,
withStyles(styles)
)(MyComponent);
Would be equivalent to exporting with:
export default withRouter(withApi(withStyles(styles)(MyComponent)));