Created
January 22, 2019 08:09
-
-
Save SirSerje/a768acb92359cc36d44a55c67e618476 to your computer and use it in GitHub Desktop.
simple hoc js usage
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
const highOrderComponent = (WrappedComponent) => { | |
class HOC extends React.Component { | |
render() { | |
return <WrappedComponent/>; | |
} | |
} | |
HOC.displayName = `HOC of ${WrappedComponent.displayName || WrappedComponent.name || 'Component'}`; | |
return HOC; | |
}; | |
// usage | |
// const WrappedCoponent = highOrderComponent(Message); | |
// <WrappedCoponent/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment