import React, { Component } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';

export const imShallowEqual = require('./imShallowEqual');

export default (Comp) => {
    const RetComp = class extends Component {
        constructor(props) {
            super(props);
        }
        shouldComponentUpdate(nextProps, nextState) {
            return !(imShallowEqual(this.props, nextProps) && imShallowEqual(this.state, nextState));
        }
        render() {
            return <Comp {...this.props} />
        }
    }
    hoistNonReactStatics(RetComp, Comp);
    return RetComp;
}
