Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 当React已在change select2中呈现时,无法刷新更新_Reactjs_Jquery Select2_React Select - Fatal编程技术网

Reactjs 当React已在change select2中呈现时,无法刷新更新

Reactjs 当React已在change select2中呈现时,无法刷新更新,reactjs,jquery-select2,react-select,Reactjs,Jquery Select2,React Select,在select2下拉列表中选择时出错我正在使用react-select2作为国家/地区和城市下拉列表: 代码如下: <Select2 name="country" ref={this.state.country} value={this.state.country} data={ this.props.countries ? this.props.countries.map(e => { ret

在select2下拉列表中选择时出错我正在使用react-select2作为国家/地区和城市下拉列表:

代码如下:

<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);
         }}
        />
{
返回{
id:e.id,
文本:e.名称,
};
})
:
[]
}
选择权={
{
dropdownParent:“.dropdown国家/地区字段”
}
}
onChange={(e)=>{
这是我的国家({
国家:e.target.value
})
this.props.getAllCities(this.state.country);
}}
/>

setState中的这个e.target.value不起作用,相反,您需要先获取该值,(e)=>{const{value}=e.target;This.setState({country:value})仍然会收到相同的警告错误