// @flow import React, { Component } from 'react'; type Props = { value: T, options: T[], ariaLabel: string, formatTitle: (option: T) => any, extra?: any, onChange: (value: T) => void }; type State = { expanded: boolean }; export default class DropdownComponent extends Component< void, Props, State > { props: Props; state = { expanded: false }; render() { const { options, value, ariaLabel, extra } = this.props; const { expanded } = this.state; return ( {expanded && } ); } formatTitle(option: any) { return this.props.formatTitle(option); } toggleExpanded = () => { this.setState(state => { return { expanded: !state.expanded }; }); }; onChange = (value: any) => { this.props.onChange(value); this.setState({ expanded: false }); }; }