import React from 'react'; import Select, { ReactSelectProps, Option } from 'react-select'; interface Props extends ReactSelectProps { className?: string; options: any; onChange: any; } export default class Dropdown extends React.Component { public state = { selectedOption: { value: '', label: '' }, hasBlurred: false }; public handleChange = (selectedOption: Option) => { this.setState({ selectedOption }); }; public formatOptions = (options: Option[]) => { if (typeof options[0] === 'object') { return options; } const formatted = options.map(opt => { return { value: opt, label: opt }; }); return formatted; }; public render() { const { onChange } = this.props; const { selectedOption } = this.state; const value = selectedOption && selectedOption.value; const options = this.formatOptions(this.props.options); return (