I am implementing React-Select Async. According to their documentation, my code is correct. Yet, onInputChange throws the error "Cannot read property 'replace' of undefined"each as soon as I type something. How to fix this?
const options=[
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' }
]
export default function App() {
const [query, setQuery] = useState('')
const handleInputChange = (str) => {
const inputValue = str.replace(/\W/g, '');
setQuery(inputValue);
return inputValue;
};
return (
<>
<AsyncSelect
cacheOptions
//loadOptions={loadOptions}
defaultOptions={options}
onInputChange={(e)=> handleInputChange(e.target.value)}
/>
</>
);
}