Skip to content

Instantly share code, notes, and snippets.

@alexdmejias
Created April 21, 2017 19:59
Show Gist options
  • Save alexdmejias/34800ee2b8e165ac6638502ddd38982c to your computer and use it in GitHub Desktop.
Save alexdmejias/34800ee2b8e165ac6638502ddd38982c to your computer and use it in GitHub Desktop.
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