We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 660bc9a commit 8bd8d2bCopy full SHA for 8bd8d2b
src/table/Row/useDoubleClick.ts
@@ -14,23 +14,23 @@ const useDoubleClickBase = ({
14
onSingleClick: (e: Event) => void;
15
onDoubleClick: ((e: Event) => void) | null;
16
}) => {
17
+ const clickCount = React.useRef(0);
18
+
19
React.useEffect(() => {
20
const { current } = ref;
21
- let clickCount = 0;
-
22
const handleDoubleClick = (event: any) => {
23
if (onDoubleClick) {
24
- if (clickCount === 0) {
+ if (clickCount.current === 0) {
25
onSingleClick(event);
26
}
27
28
- clickCount += 1;
+ clickCount.current += 1;
29
30
setTimeout(() => {
31
- if (clickCount === 2) onDoubleClick(event);
+ if (clickCount.current === 2) onDoubleClick(event);
32
33
- clickCount = 0;
+ clickCount.current = 0;
34
}, 300);
35
36
};
0 commit comments