Skip to content

Instantly share code, notes, and snippets.

@jide
Created December 8, 2016 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jide/81dce69316d3f40d3b77e4f380c4a230 to your computer and use it in GitHub Desktop.
Save jide/81dce69316d3f40d3b77e4f380c4a230 to your computer and use it in GitHub Desktop.
let WrappedComponent;
if (Component.prototype.render) {
WrappedComponent = type;
}
// If it is a stateless component, we wrap it in a stateful component to be able to use lifecycle
// hooks.
else {
WrappedComponent = class extends Component {
render() {
return type(this.props);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment