const [country, set_country] = useState();
<Autocomplete
autoHighlight={true} //needed
autoSelect={true}
id="geo-select-country"
options={all_country}
value={country} // culprit that causes red warning
onChange={(event, selected_country) => {
set_country(selected_country);
}}
classes={autocomplete_classes}
renderInput={(params) => (
<TextField {...params} label={"Country"} margin="none" focused />
)}
/>
warning message:
index.js:1 MUI: A component is changing the uncontrolled value state of Autocomplete to be controlled.
Elements should not switch from uncontrolled to controlled (or vice versa).
Decide between using a controlled or uncontrolled Autocomplete element for the lifetime of the component.
The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.
The AutoComplete modifies the useState, but the value of the useState modifies the AutoComplete.
Is this not correct?