<commit_before>import { cloneElement, Component, PropTypes } from 'react';
import reducer from './reducers';

export default class FilterMonitor extends Component {
  static update = reducer;

  static propTypes = {
    children: PropTypes.element,
    whitelist: PropTypes.array,
    blacklist: PropTypes.array
  };

  render() {
    const { whitelist, blacklist, monitorState, children, ...rest } = this.props;

    if (whitelist || blacklist) {
      let { stagedActionIds, actionsById } = rest;
      stagedActionIds = stagedActionIds.filter(id => {
        const action = actionsById[id].action;
        return (
          whitelist && whitelist.indexOf(action.type) !== -1 ||
          blacklist && blacklist.indexOf(action.type) === -1
        );
      });

      rest = {
        ...rest,
        stagedActionIds: stagedActionIds
      };
    }

    const childProps = {
      ...rest,
      monitorState: monitorState.childMonitorState || {}
    };
    return cloneElement(children, childProps);
  }
}<commit_msg>Filter computedStates along with stagedActionIds<commit_after>import { cloneElement, Component, PropTypes } from 'react';
import reducer from './reducers';

export default class FilterMonitor extends Component {
  static update = reducer;

  static propTypes = {
    children: PropTypes.element,
    whitelist: PropTypes.array,
    blacklist: PropTypes.array
  };

  isFiltered(action) {
    return (
      this.props.whitelist && this.props.whitelist.indexOf(action) !== -1 ||
      this.props.blacklist && this.props.blacklist.indexOf(action) === -1
    );
  }

  render() {
    const {
        whitelist, blacklist, monitorState, children,
        stagedActionIds, computedStates,
        ...rest
      } = this.props;
    const filteredStagedActionIds = [];
    const filteredComputedStates = [];

    if (whitelist || blacklist) {
      stagedActionIds.forEach((id, idx) => {
        if (this.isFiltered(rest.actionsById[id].action.type)) {
          filteredStagedActionIds.push(id);
          filteredComputedStates.push(computedStates[idx]);
        }
      });

      rest = {
        ...rest,
        stagedActionIds: filteredStagedActionIds,
        computedStates: filteredComputedStates
      };
    } else {
      rest = {
        ...rest,
        stagedActionIds, computedStates
      };
    }

    const childProps = {
      ...rest,
      monitorState: monitorState.childMonitorState || {}
    };
    return cloneElement(children, childProps);
  }
}
{'fraction_non_alphanumeric': 0.11856913183279742, 'fraction_numerical': 0.001607717041800643, 'mean_word_length': 2.602026049204052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2317599', 'n_tokens_mistral': 716, 'n_tokens_neox': 704, 'n_words': 147}