refactor: Dropdown component

This commit is contained in:
Francesco Esposito 2019-07-31 15:54:20 +02:00
parent 289f01a359
commit a7ce3013ab
1 changed files with 13 additions and 21 deletions

View File

@ -1,32 +1,24 @@
import React, { Component } from 'react'; import React from 'react';
import { Input } from 'reactstrap'; import { Input } from 'reactstrap';
class DropDown extends Component { const DropDown = (props) => {
constructor(props) { let options = props.options;
super(props); options = options.map((opt) => {
return <option key={opt.name} value={opt.name}>{opt.value}</option>
});
this.state = {}; return (
}
render() {
let options = this.props.options;
options = options.map((opt) => {
return <option key={opt.name} value={opt.name}>{opt.value}</option>
});
return(
<Input <Input
name = {this.props.name} name={props.name}
type = "select" type="select"
value = { this.props.value } value={props.value}
onChange = { this.props.onChange } onChange={props.onChange}
> >
<option value="">---</option> <option value="">---</option>
{ options } {options}
</Input> </Input>
); );
}
} }
export default DropDown; export default DropDown;