Created
December 8, 2016 12:13
-
-
Save jide/81dce69316d3f40d3b77e4f380c4a230 to your computer and use it in GitHub Desktop.
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
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