✅ – ✅ – weeBlord – 11-12 Jan 22
Original message was deleted
Solution
Like
const [shouldExecuteClick, setShouldExecuteClick] = useState(true);
const longClickTimeoutRef = useRef();
const onMouseDown = () => {
longClickTimeoutRef.current = setTimeout(() => setShouldExecuteClick(false), 10000);
}
const onMouseUp = () => {
clearTimeout(longClickTimeoutRef.current);
if (shouldExecuteClick) {
// properly handle the click
}
setShouldExecuteClick(true);
}const [shouldExecuteClick, setShouldExecuteClick] = useState(true);
const longClickTimeoutRef = useRef();
const onMouseDown = () => {
longClickTimeoutRef.current = setTimeout(() => setShouldExecuteClick(false), 10000);
}
const onMouseUp = () => {
clearTimeout(longClickTimeoutRef.current);
if (shouldExecuteClick) {
// properly handle the click
}
setShouldExecuteClick(true);
}