2018-09-17 14:01:51 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
options: string[],
|
2018-09-17 16:31:19 +02:00
|
|
|
optionSelected: string => void,
|
|
|
|
|
preselectedOption: string
|
2018-09-17 14:01:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DropDown extends React.Component<Props> {
|
|
|
|
|
render() {
|
2018-09-17 16:31:19 +02:00
|
|
|
const {options, preselectedOption} = this.props;
|
|
|
|
|
return <select value={preselectedOption} onChange={this.change}>
|
2018-09-17 16:51:09 +02:00
|
|
|
<option key=""> </option>
|
2018-09-17 14:01:51 +02:00
|
|
|
{options.map(option => {
|
2018-09-17 16:31:19 +02:00
|
|
|
return <option key={option}
|
|
|
|
|
value={option}>{option}</option>
|
2018-09-17 14:01:51 +02:00
|
|
|
})}
|
|
|
|
|
</select>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
change = (event) => {
|
|
|
|
|
this.props.optionSelected(event.target.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DropDown;
|