Cannot flush updates when React is already rendering in on change select2

3.7k Views Asked by At

Getting the error on select in select2 dropdown I'm using react-select2 for country and city dropdown : enter image description here

Following is the code:

<Select2
     name="country"
     ref={this.state.country}
     value={this.state.country}
     data={
     this.props.countries ? this.props.countries.map(e => {
         return {
               id: e.Id,
               text: e.Name,
               };
         })
          :
            []
          }
          options={
          {
            dropdownParent: '.dropdown-country-field'
           }
         }
         onChange={(e) => {
                this.setState({
                country: e.target.value
                })
          this.props.getAllCities(this.state.country);
         }}
        />
0

There are 0 best solutions below