<commit_before>import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import Select from 'react-select';
import selectStyles from '../../styles/select';

const MultiSelectField = createReactClass({
  displayName: 'MultiSelectField',
  propTypes: {
    label: PropTypes.string,
    options: PropTypes.array,
  },

  getInitialState() {
    return {
      removeSelected: true,
      disabled: false,
      stayOpen: false,
      value: this.props.selected,
      rtl: false,
    };
  },

  handleSelectChange(value) {
    this.setState({ value });
    this.props.setSelectedFilters(value || []);
  },

  render() {
    const { disabled, stayOpen, value } = this.state;
    const options = this.props.options;<commit_msg>Fixed bug in MultiSelectField, selected options weren't updating.<commit_after>import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import Select from 'react-select';
import selectStyles from '../../styles/select';

const MultiSelectField = createReactClass({
  displayName: 'MultiSelectField',
  propTypes: {
    label: PropTypes.string,
    options: PropTypes.array,
  },

  getInitialState() {
    return {
      removeSelected: true,
      disabled: false,
      stayOpen: false,
      value: this.props.selected,
      rtl: false,
    };
  },

  componentDidUpdate(prevProps) {
    if (this.props.selected.length !== prevProps.selected.length) {
      // eslint-disable-next-line react/no-did-update-set-state
      this.setState({
        value: this.props.selected
      });
    }
  },

  handleSelectChange(value) {
    this.setState({ value });
    this.props.setSelectedFilters(value || []);
  },

  render() {
    const { disabled, stayOpen, value } = this.state;
    const options = this.props.options;
{'fraction_non_alphanumeric': 0.12898003237992445, 'fraction_numerical': 0.0, 'mean_word_length': 3.311627906976744, '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': '4043370', 'n_tokens_mistral': 538, 'n_tokens_neox': 545, 'n_words': 125}