Skip to content

Instantly share code, notes, and snippets.

@Siemko
Last active November 6, 2017 19:56
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 Siemko/e49b9337f62a41d59c4d7979f1189d70 to your computer and use it in GitHub Desktop.
Save Siemko/e49b9337f62a41d59c4d7979f1189d70 to your computer and use it in GitHub Desktop.
const Connect = ComposedComponent =>
class extends React.Component {
state = { name: "" }
componentDidMount() {
//fetching data is a part of HOC
getAsync('https://imaginary-api.gorrion.io/name')
.then(({ name }) => { this.setState({ name: name }) })
}
render() {
return (
<ComposedComponent
{...this.props}
name={this.state.name}
/>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment