import React, {Component} from 'react';
import {getDisplayName} from 'shared/utils/common';

const onMount = handler => WrappedComponent =>
  class Wrapper extends Component {
    static displayName = `OnMount(${getDisplayName(WrappedComponent)})`;

    componentDidMount() {
      handler(this.props);
    }

    render() {
      return <WrappedComponent {...this.props} />;
    }
  };

export default onMount;
