From e1eea3de89f092ce903eaa5ad7eb50d70803bd04 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 26 Oct 2021 13:25:34 +0100 Subject: [PATCH] Update SelectBox.js --- src/components/SelectBox.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/SelectBox.js b/src/components/SelectBox.js index 0b0ab01b..069deb24 100644 --- a/src/components/SelectBox.js +++ b/src/components/SelectBox.js @@ -40,13 +40,11 @@ export function SelectBox({ options, selectedItem, setSelectedItem }) { useEffect(() => { // add when mounted document.addEventListener("mousedown", handleClick); - //document.addEventListener("scroll", closeDropdown); // return function to be called when unmounted return () => { document.removeEventListener("mousedown", handleClick); - document.removeEventListener("scroll", closeDropdown) }; - }, []); + }, [handleClick]); const onOptionClick = (e, option, i) => { e.stopPropagation() @@ -68,4 +66,4 @@ export function SelectBox({ options, selectedItem, setSelectedItem }) { ) -} \ No newline at end of file +}