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

36 lines
728 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-10-04 20:02:18 +02:00
};
2018-09-17 14:01:51 +02:00
class DropDown extends React.Component<Props> {
render() {
2018-10-04 20:02:18 +02:00
const { options, preselectedOption } = this.props;
return (
<div className="select">
<select value={preselectedOption} onChange={this.change}>
<option key="" />
{options.map(option => {
return (
<option key={option} value={option}>
{option}
</option>
);
})}
</select>
</div>
);
2018-09-17 14:01:51 +02:00
}
2018-10-04 20:02:18 +02:00
change = event => {
2018-09-17 14:01:51 +02:00
this.props.optionSelected(event.target.value);
2018-10-04 20:02:18 +02:00
};
2018-09-17 14:01:51 +02:00
}
export default DropDown;