From 3548451cc4ac0cde0f7a0ab8828f0176f6bf9ed8 Mon Sep 17 00:00:00 2001 From: Tomer Hirshfeld Date: Mon, 22 Apr 2024 11:53:00 +0300 Subject: [PATCH] fixed click + rerender + click being interpreted as two single clicks instead of one double click --- src/__tests__/use-double-click.test.js | 15 +++++++++++++++ src/index.js | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/__tests__/use-double-click.test.js b/src/__tests__/use-double-click.test.js index d7c9da0..49571be 100644 --- a/src/__tests__/use-double-click.test.js +++ b/src/__tests__/use-double-click.test.js @@ -36,6 +36,21 @@ test('calls "onDoubleClick" callback on double click', async () => { expect(onDoubleClick).toHaveBeenCalledTimes(1); }); +test('calls "onDoubleClick" callback on double click despite rerender between clicks', async () => { + const onDoubleClick = jest.fn(); + const { getByText, rerender } = render( +