<commit_before>import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import Items from './Items';
import { toggleItem } from '../actions';

const getVisibleItems = (
  items,
  filter
) => {
  switch (filter) {
    case 'all':
      return items;
    case 'enabled':
      return items.filter(
        i => i.enabled
      );
    case 'disabled':
      return items.filter(
        i => !i.enabled
      );
    default:
      throw new Error(`Unknown filter: ${filter}.`);
  }
}

const mapStateToProps = (state, { match }) => {
  return {
    items: getVisibleItems(
      state.items,
      match.params.filter || 'all'
    )
  };
}

const mapDispatchToProps = (dispatch) => {
  return {
    onItemClick: id => {
      dispatch(
        toggleItem(id)
      )
    }
  };
}

const VisibleItems = withRouter(
  connect(
    mapStateToProps,
    mapDispatchToProps
  )(Items)
);

export default VisibleItems;<commit_msg>refactor: Using mapDispatchToProps() Shorthand Notation<commit_after>import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import Items from './Items';
import { toggleItem } from '../actions';

const getVisibleItems = (
  items,
  filter
) => {
  switch (filter) {
    case 'all':
      return items;
    case 'enabled':
      return items.filter(
        i => i.enabled
      );
    case 'disabled':
      return items.filter(
        i => !i.enabled
      );
    default:
      throw new Error(`Unknown filter: ${filter}.`);
  }
}

const mapStateToProps = (state, { match }) => {
  return {
    items: getVisibleItems(
      state.items,
      match.params.filter || 'all'
    )
  };
}

const VisibleItems = withRouter(
  connect(
    mapStateToProps,
    { onItemClick: toggleItem }
  )(Items)
);

export default VisibleItems;
{'fraction_non_alphanumeric': 0.13638873550524572, 'fraction_numerical': 0.0, 'mean_word_length': 2.5599214145383105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5913295', 'n_tokens_mistral': 572, 'n_tokens_neox': 568, 'n_words': 140}