Kliknij dwukrotnie reaguj
const [nrTaps, setNrTaps] = useState<number>(0);
const [startDate, setStartDate] = useState<number>(Date.now());
const touchStart = () => {
if (nrTaps >= 1 && Date.now() - startDate < 500) {
setStartDate(Date.now());
setNrTaps(0);
// double tap
} else {
setStartDate(Date.now());
setNrTaps(prevNr => prevNr + 1);
// single tap;
}
};
Grumpy Goat