Skip to content

Instantly share code, notes, and snippets.

@Mayankgupta688
Created April 29, 2019 09:55
Show Gist options
  • Save Mayankgupta688/836e338e7b915f80b190b07dbf6daf62 to your computer and use it in GitHub Desktop.
Save Mayankgupta688/836e338e7b915f80b190b07dbf6daf62 to your computer and use it in GitHub Desktop.
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