From 759e6980ac5d49816c6d35d78c80f49e6e0e8fab Mon Sep 17 00:00:00 2001 From: Rajat Kanti Nandi Date: Thu, 2 Jan 2020 02:21:54 +0530 Subject: [PATCH] Fix setDirection triggering twice --- package.json | 2 +- src/useSwipe.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea19939..a7074b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "use-swipe-hook", - "version": "1.0.3", + "version": "1.0.4", "description": "A simple and easy to use tiny library that provides useSwipe hook to use with React that enables swipe gestures for touch screens", "main": "lib/index.umd.js", "browser": "lib/index.umd.js", diff --git a/src/useSwipe.js b/src/useSwipe.js index 342055b..81ad6bc 100644 --- a/src/useSwipe.js +++ b/src/useSwipe.js @@ -14,7 +14,7 @@ const useSwipe = ({ ref, thresholdPX = 5 }) => { setDirection(y2 > y1 ? 'down' : 'up'); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [x2, y2, thresholdPX]); + }, [y2]); React.useEffect(() => { const currentElement = ref.current;