From 6acb132aefcf6c2a48a35baec4a9fb2f35587e86 Mon Sep 17 00:00:00 2001 From: Marnus Weststrate Date: Thu, 13 Oct 2022 17:03:18 +0100 Subject: [PATCH] fix: useEventListener removeEventListener options Options passed to addEventListener and removeEventListener must match for the listener to be removed. --- src/useEventListener/useEventListener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useEventListener/useEventListener.ts b/src/useEventListener/useEventListener.ts index 2655e2c9..fa17a16a 100644 --- a/src/useEventListener/useEventListener.ts +++ b/src/useEventListener/useEventListener.ts @@ -74,7 +74,7 @@ function useEventListener< // Remove event listener on cleanup return () => { - targetElement.removeEventListener(eventName, listener) + targetElement.removeEventListener(eventName, listener, options) } }, [eventName, element, options]) }