Created
April 21, 2017 19:59
-
-
Save alexdmejias/34800ee2b8e165ac6638502ddd38982c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Enhance = InnerComponent => class extends React.Component { | |
render() { | |
return <InnerComponent {...this.props} data={"wasdwasd"} />; | |
} | |
}; | |
// HOC Usage | |
// import { Enhance } from "./Enhance"; | |
class MyComponent extends React.Component { | |
render() { | |
if (!this.props.data) return <div>Waiting...</div>; | |
return <div>{this.props.data}</div>; | |
} | |
} | |
export default Enhance(MyComponent); // Enhanced component |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment