How to receive data from a select correctly in react so that the selected / typed data is then saved?

0

How to receive data from a select correctly in react so that the selected / typed data is then saved?

Thanks in advance,

constructor(props) {
    super(props);
    this._handleSelect = this._handleSelect.bind(this)

    this.state = {
        selectCity: '',
    }
}

_handleSelect(e) {
    this.setState({
        selectCity: e.target.value,
    });
 }
<Row style = {{marginTop: 10}}>
    <Col xs="12">
        <FormGroup>
            <Label htmlFor="city">Cidade</Label>
            <Input maxLength={50}
              type="select"
              id="city"
              name="city"
              invalid={this.props.ErrorList.indexOf('city') > -1}
              value={this.state.selectCity} 
              onChange={this._handleSelect}
              required>
                <option>Selecione sua cidade</option>
                {
                    this.props.CityList.map((item) =>{
                        return (
                          <option key={item.id} value={item.id}>{item.name}</option>
                        )
                     })
                }
             </Input>
             <FormFeedback>campo obrigatório</FormFeedback>
        </FormGroup>
    </Col>
</Row>
    
asked by anonymous 18.12.2018 / 19:58

0 answers