Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created June 19, 2021 20:11
Show Gist options
  • Save sabesansathananthan/62be6f9571edc6427c70aea3b5b010bb to your computer and use it in GitHub Desktop.
Save sabesansathananthan/62be6f9571edc6427c70aea3b5b010bb to your computer and use it in GitHub Desktop.
How React Components Are Reused
const EnhancedComponent = withRouter(connect(commentSelector)(WrappedComponent))
// You can write combined tool functions
// compose(f, g, h) Equivalent to (...args) => f(g(h(...args)))
const enhance = compose(
// These are single-parameter HOCs
withRouter,
connect(commentSelector)
)
const EnhancedComponent = enhance(WrappedComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment