Skip to content

Instantly share code, notes, and snippets.

@cecigarcia
Created March 25, 2020 18:54
Show Gist options
  • Save cecigarcia/3f09deeb796f7ed96f0dbc99eea68e8d to your computer and use it in GitHub Desktop.
Save cecigarcia/3f09deeb796f7ed96f0dbc99eea68e8d to your computer and use it in GitHub Desktop.
import React from "react";
import useClickPrevention from "./use-click-prevention";
const MyComponent = () => {
const onClick = () => console.log("single click");
const onDoubleClick = () => console.log("double click");
const [onClickWithPrevention, onDoubleClickWithPrevention] = useClickPrevention({ onClick, onDoubleClick });
return (
<div
className="clickable-container"
onClick={onClickWithPrevention}
onDoubleClick={onDoubleClickWithPrevention}
/>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment