Files
SCM-Manager/scm-ui/src/repos/components/DropDown.js

31 lines
654 B
JavaScript
Raw Normal View History

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