Created
April 29, 2019 09:55
-
-
Save Mayankgupta688/836e338e7b915f80b190b07dbf6daf62 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
import React from 'react'; | |
var newData = { | |
data: 'Data from HOC...', | |
} | |
var MyHOC = ComposedComponent => class extends React.Component { | |
componentDidMount() { | |
this.setState({ | |
data: newData.data | |
}); | |
} | |
render() { | |
return <ComposedComponent {...this.props} {...this.state} />; | |
} | |
}; | |
class MyComponent extends React.Component { | |
render() { | |
return ( | |
<div> | |
<h1>{this.props.data}</h1> | |
</div> | |
) | |
} | |
} | |
export default MyHOC(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment