React drop-down box after selecting a value, how to reset (the Ant Design) used

how to reset

after selecting a value in the drop-down box
this.state({
    code: "",
    codeList: "",
})

componentWillMount(){
   init(); //
}

<Select
    ref="xzSelect"
    defaultValue=""
    onSelect={val => this.setState({code:val})}
>
    {this.state.codeList}
</Select>
Feb.27,2021

two ideas

1. Load a new Select when you need to reset, and you can use the key value to forcibly refresh

.

2. Make it a controlled component, manually control value of Select , and change the selected option

with onSelect .
<Select
    ref="xzSelect"
    placeholder=""
    value={this.state.val}
    allowclear
    onChange={val => this.setState({code:val})}
>
    {this.state.codeList}
</Select>

you just need to make the component controllable.
, which is the method upstairs, add value and onChange

Menu