{"size": 918, "ext": "js", "max_stars_repo_path": "packages/patternfly-4/react-core/src/components/Select/examples/SelectInputInvalid.js", "max_stars_repo_name": "dtaylor113/patternfly-react", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/patternfly-4/react-core/src/components/Select/examples/SelectInputInvalid.js", "max_issues_repo_name": "dtaylor113/patternfly-react", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/patternfly-4/react-core/src/components/Select/examples/SelectInputInvalid.js", "max_forks_repo_name": "dtaylor113/patternfly-react", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5, "max_line_length": 115, "alphanum_fraction": 0.5904139434}
import React from 'react';
import { Select, SelectOption } from '@patternfly/react-core';

class SelectInputInvalid extends React.Component {
  state = {
    value: '',
  };

  isEmpty = () => {
    return this.state.value !== '';
  }

  onChange = (value, event) => {
    this.setState({ value });
  };

  options = [
    { value: '', label: 'Choose a number', disabled: false },
    { value: '1', label: 'One', disabled: false },
    { value: '2', label: 'Two', disabled: false },
    { value: '3', label: 'Three', disabled: false },
  ];

  render() {
    return (
      <Select isValid={this.isEmpty()} value={this.state.value} onChange={this.onChange} aria-label="Select Input">
        {this.options.map((option, index) => (
          <SelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
        ))}
      </Select>
    );
  }
}

export default SelectInputInvalid;
