<commit_before>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import _get from '../utils/get';
import map from '../utils/map';
import iteratee from '../utils/iteratee';
import isPlainObject from '../utils/is-plain-object';
import omit from '../utils/omit';

import getForm from '../utils/get-form';
import getFieldFromState from '../utils/get-field-from-state';
import getModel from '../utils/get-model';
import isValid from '../form/is-valid';
import resolveModel from '../utils/resolve-model';
import initialFieldState from '../constants/initial-field-state';
import shallowEqual from '../utils/shallow-equal';
import invariant from 'invariant';

const defaultStrategy = {
  get: _get,
  getForm,
  getFieldFromState,
};

const propTypes = {
  // Computed props
  modelValue: PropTypes.any,
  formValue: PropTypes.object,
  fieldValue: PropTypes.object,

  // Provided props
  model: PropTypes.string.isRequired,
  messages: PropTypes.objectOf(PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.bool,
  ])),
  show: PropTypes.any,
  wrapper: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.element,
  ]),
  component: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.element,
  ]),
  dispatch: PropTypes.func,
  dynamic: PropTypes.oneOfType([
    PropTypes.bool,
    PropTypes.arrayOf(PropTypes.string),
  ]),
  store: PropTypes.shape({
    subscribe: PropTypes.func,
    dispatch: PropTypes.func,
    getState: PropTypes.func,
  }),
};

function showErrors(field, form, show = true) {
  if (typeof show === 'function') {
    return show(field, form);
  }

  if (!Array.isArray(show)
    && typeof show !== 'object'
    && typeof show !== 'string') {
    return !!show;
  }

  return iteratee(show)(field);
}

function createErrorsClass(s = defaultStrategy) {
  class Errors extends Component {
    shouldComponentUpdate(nextProps) {
      const { fieldValue, formValue } = nextProps;
      const { dynamic } = this.props;

      if (dynamic) {
        return !shallowEqual(this.props, nextProps);
      }

      return fieldValue !== this.props.fieldValue<commit_msg>Preventing storeSubscription from being passed down to Errors. Fixes #698<commit_after>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import _get from '../utils/get';
import map from '../utils/map';
import iteratee from '../utils/iteratee';
import isPlainObject from '../utils/is-plain-object';
import omit from '../utils/omit';

import getForm from '../utils/get-form';
import getFieldFromState from '../utils/get-field-from-state';
import getModel from '../utils/get-model';
import isValid from '../form/is-valid';
import resolveModel from '../utils/resolve-model';
import initialFieldState from '../constants/initial-field-state';
import shallowEqual from '../utils/shallow-equal';
import invariant from 'invariant';

const defaultStrategy = {
  get: _get,
  getForm,
  getFieldFromState,
};

const propTypes = {
  // Computed props
  modelValue: PropTypes.any,
  formValue: PropTypes.object,
  fieldValue: PropTypes.object,

  // Provided props
  model: PropTypes.string.isRequired,
  messages: PropTypes.objectOf(PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.bool,
  ])),
  show: PropTypes.any,
  wrapper: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.element,
  ]),
  component: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
    PropTypes.element,
  ]),
  dispatch: PropTypes.func,
  dynamic: PropTypes.oneOfType([
    PropTypes.bool,
    PropTypes.arrayOf(PropTypes.string),
  ]),
  store: PropTypes.shape({
    subscribe: PropTypes.func,
    dispatch: PropTypes.func,
    getState: PropTypes.func,
  }),
  storeSubscription: PropTypes.any,
};

function showErrors(field, form, show = true) {
  if (typeof show === 'function') {
    return show(field, form);
  }

  if (!Array.isArray(show)
    && typeof show !== 'object'
    && typeof show !== 'string') {
    return !!show;
  }

  return iteratee(show)(field);
}

function createErrorsClass(s = defaultStrategy) {
  class Errors extends Component {
    shouldComponentUpdate(nextProps) {
      const { fieldValue, formValue } = nextProps;
      const { dynamic } = this.props;

      if (dynamic) {
        return !shallowEqual(this.props, nextProps);
      }

      return fieldValue !== this.props.fieldValue
{'fraction_non_alphanumeric': 0.1367274344152957, 'fraction_numerical': 0.0006669630947087594, 'mean_word_length': 3.638144329896907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1061513', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1364, 'n_words': 330}