I have used material UI AutoCompleteBox here it's Link:https://material-ui.com/components/autocomplete/
My code is:
<Autocomplete
open={showUniSuggs}
onOpen={this.props.getUniversityOptions}
onChange={(event, value) =>
this.props.handleUniversityChange(value)
}
onClose={this.props.onUniversityClose}
getOptionLabel={(option) => option._id}
options={universityOptions}
loading={uniLoading}
// disabled={disableUniversity}
renderInput={(params) => (
<TextField
{...params}
label="Search for university"
fullWidth
variant="filled"
margin="dense"
InputProps={{
...params.InputProps,
endAdornment: (
<React.Fragment>
{uniLoading ? (
<CircularProgress color="inherit" size={20} />
) : null}
{params.InputProps.endAdornment}
</React.Fragment>
),
}}
/>
)}
/>
Whenever click on Autocomplete search bar API is called and data is saved on getUniversityOptions Select any Value then we click on the cross icon of Autocomplete search bar and data has cleared. But I want that this data will clear using Onclick function Whenever Click on Button the data will clear. So How it's possible to do it.
you can set value property with empty string to clear the value like
here is the complete example: