Skip to content

Instantly share code, notes, and snippets.

@ncuillery
Created May 23, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncuillery/5684ca5002cca50b7122ebca4aa43faa to your computer and use it in GitHub Desktop.
Save ncuillery/5684ca5002cca50b7122ebca4aa43faa to your computer and use it in GitHub Desktop.
ReactEurope2017_4
// Instead of doing this...
const EnhancedComponent = connect(commentSelector)(withRouter(WrappedComponent))
// ... you can use a function composition utility
// compose(f, g, h) is the same as (...args) => f(g(h(...args)))
const enhance = compose(
// These are both single-argument HOCs
connect(commentSelector),
withRouter
)
const EnhancedComponent = enhance(WrappedComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment