From 101b00633ff87606697b4b2e5f48eca1f96bf79c Mon Sep 17 00:00:00 2001 From: jongomez Date: Fri, 29 Sep 2023 13:04:35 +0100 Subject: [PATCH] refactor: remove unnecessary useEffect --- packages/lsd-react/src/components/Dropdown/Dropdown.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx index da34aeb..dd5a29a 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx @@ -59,6 +59,8 @@ export const Dropdown: React.FC & { const isControlled = isOpen !== undefined const [openState, setOpenState] = useState(false) + if (isControlled && isOpen !== openState) setOpenState(isOpen) + const { select, isSelected, selected } = useSelect(options, value, { multi, onChange, @@ -81,10 +83,6 @@ export const Dropdown: React.FC & { handleToggle(!openState) } - useEffect(() => { - if (disabled && openState && !isControlled) setOpenState(false) - }, [open, disabled, isControlled]) - // Handle the controlled version of the component: useEffect(() => { typeof isOpen !== 'undefined' && setOpenState(isOpen)