I want to call api request 2 seconds after clicking on the last digit. I wanted to add lodash debounce and after that I can't write value in the input. event target value does not work after adding debounce , please tell me what I wrote wrong.
const handleChange = (event, onChange) => {
try {
const response = searchContractorsById(event.target.value);
const { address, inn, orgName, ogrn, kpp, okpo, okved } = response;
toast.success('Найдена организация по введенному ИНН.');
} catch (error) {
toast.error('По введенному ИНН не найдено ни одной организации.');
}
onChange(event);
};
<Controller
name="inn"
control={control}
render={({ field: { value, onChange } }) => (
<TextField
value={value}
onChange={debounce((e) => handleChange(e, onChange), 2000)}
type="number"
/>
)}
/>