Response 'ItemData' will have n number of fields, i want to retrieve specific field, eg'itemNo' and set it to 'ItemData'. Instead of the whole response. So that i can use that in getOptionLabel of autocomplete. As I would like to set 'option => option' instead of 'option => option.specificFieldName' as per my requirement.
onChangeInputItemNo = value => {
getItem(value).then(
(response) => {
if (response.ok) {
response.json()
.then((responseData) => {
console.log(responseData);
console.log("hi");
this.setState({
isLoading: false,
ItemData: responseData
})
});
}
})
}
I will be passing initial value to autocomplete box from child component, also i want the autocomplete to work as normal, if value needed to be changed. So i like to keep getOptionLabel as 'option' instead of 'option.specficFieldName'.
<Autocomplete
value={this.state.fromChild}
options={this.state.ItemData}
getOptionLabel={option => option}
onChange={this.onChangeItemNo}
renderInput={params => (
<TextField {...params} onChange={e => this.onChangeInputItemNo(e.target.value)} fullWidth />
)}
/>