// @flow import React, { Component } from 'react'; import PropTypes from 'prop-types'; export default class DropdownComponent extends Component { static propTypes = { value: PropTypes.object.isRequired, options: PropTypes.arrayOf(PropTypes.object).isRequired, ariaLabel: PropTypes.string.isRequired, formatTitle: PropTypes.func.isRequired, extra: PropTypes.node, onChange: PropTypes.func.isRequired }; // FIXME props: { value: any, options: any[], ariaLabel: string, formatTitle: (option: any) => any, extra?: any, onChange: () => void }; state = { expanded: false }; render() { const { options, value, ariaLabel, extra } = this.props; return ( {this.state.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 }); }; }