Last active
March 23, 2018 15:23
-
-
Save prichodko/812de41e69c997e4adc5b13fe2d2614e to your computer and use it in GitHub Desktop.
How to write higher-order components
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 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