use-double-click is a simple React hook for differentiating single and double clicks on the same component.
Native onClick() + onDoubleClick()[native] onClick: 0[native] onDoubleClick: 0
useDoubleClick() Hook[hook] onSingleClick: 0[hook] onDoubleClick: 0
What's wrong with native
When you double click on a React component, it's
onClick() callback fires twice alongside your single
onDoubleClick() callback. This effect isn't desirable when a single click and a double click have different functions!
useDoubleClick() waits within a latency window after a click for a secondary click, and only after this period either the
onDoubleClick()callback will fire a single time.
This library is built with hooks and requires React >= 16.8.0