import { pick, isEqualWith, isFunction } from "lodash";
var shouldRerender = function shouldRerender(propKeys, stateKeys, that) {
  if (!that.hasRendered) {
    that.hasRendered = true;
    return true;
  }
  var nextProps = that.props;
  var oldProps = that.oldProps || {};
  var a = !isEq(pick(nextProps, propKeys), pick(oldProps, propKeys));
  that.oldProps = nextProps;
  var nextState = that.state;
  var oldState = that.oldState || {};
  var b = !isEq(pick(nextState, stateKeys), pick(oldState, stateKeys)) || !isEq;
  that.oldState = nextState;
  return a || b;
};
export default shouldRerender;
var isEq = function isEq(o1, o2) {
  var isEq = isEqualWith(o1, o2, function (val1, val2) {
    if (isFunction(val1) && isFunction(val2)) {
      return val1 === val2 || val1.toString() === val2.toString();
    }
  });
  return isEq;
};