//@flow import React from "react"; import {LabelWithHelpIcon} from "../index"; export type SelectItem = { value: string, label: string }; type Props = { label?: string, options: SelectItem[], value?: SelectItem, onChange: string => void, helpText?: string }; class Select extends React.Component { field: ?HTMLSelectElement; componentDidMount() { // trigger change after render, if value is null to set it to the first value // of the given options. if (!this.props.value && this.field && this.field.value) { this.props.onChange(this.field.value); } } handleInput = (event: SyntheticInputEvent) => { this.props.onChange(event.target.value); }; render() { const { options, value, label, helpText } = this.props; return (
); } } export default Select;