Created
January 17, 2017 03:01
-
-
Save poberwong/d1135db22b043419c50084e171840ec7 to your computer and use it in GitHub Desktop.
a simple high order component
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
export default (Component) => (props) => { | |
return ( | |
<YourWrapper ...> | |
<Component /> | |
</YourWrapper> | |
) | |
} | |
// Usage: | |
// in your component, you can use it with | |
export default highOrderComponent(YourComponent), it will be wrappered by <YourWrapper /> | |
// or | |
module.exports = highOrderComponent(YourComponent) | |
// of course, you can use it like following with annotation above declaration of the component | |
@highOrderComponent | |
export default ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As we all know, react-redux is a known highOrderComponent, you can use it like following:
// When using
// Of course, you can use normal class component on the last layer of arrow functions.