Siemko
11/6/2017 - 2:24 PM

connect.jsx

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}
        />
      )
    }
  }