Skip to content

Instantly share code, notes, and snippets.

@prichodko
Last active March 23, 2018 15:23
Show Gist options
  • Save prichodko/812de41e69c997e4adc5b13fe2d2614e to your computer and use it in GitHub Desktop.
Save prichodko/812de41e69c997e4adc5b13fe2d2614e to your computer and use it in GitHub Desktop.
How to write higher-order components
import hoistNonReactStatics from 'hoist-non-react-statics'
const withSomething = Component => {
const C = props => {
const { } = props // work with props if needed
return (
// render logic
<Component {...props} />
)
}
C.displayName = `withSomething(${Component.displayName || Component.name})`
C.WrappedComponent = Component
return hoistStatics(C, Component)
}
export default withSomething
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment