I have an Ant Design Autocomplete component in the header of my page (used for searching). I want to clear the text every time there is a route change. This is the code for the Autocomplete:
<AutoComplete
dataSource={options}
onSelect={this.onSelectOption}
onSearch={this.search}
labelInValue
optionLabelProp="option"
defaultActiveFirstOption={false}
>
<Input
ref={input => {
this.searchBar = input;
}}
onPressEnter={e => this.goTo(e)}
/>
</AutoComplete>
I've tried using the value property of the autocomplete and setting it in state but nothing happens. Also tried setting the value in the child Input box but again nothing happens there either. Also tried doing this.searchBar.value = "test"; but nothing.
Notes:
- I'm using ref and and Input child component because I need to be able to set focus dynamically as well as call the onPressEnter