- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
const price = Number(event.target.value);
setPrice(price);
if (timer) {
clearTimeout(timer);
setTimer(null);
}
const validPrice = validatePrice(price);
if (event.target.id.includes("cause")) {
handleOnChange(validPrice);
} else {
const timerId: any = setTimeout(() => {
setPrice(validPrice);
handleOnChange(validPrice);
}, 1000);
setTimer(timerId);
}
};
Комментарии (1) RSS