mirror of
https://github.com/acid-info/lsd.git
synced 2025-01-12 10:04:24 +00:00
refactor: remove unnecessary useEffect
This commit is contained in:
parent
b736c4de23
commit
ce779c3903
@ -59,6 +59,8 @@ export const Dropdown: React.FC<DropdownProps> & {
|
|||||||
const isControlled = isOpen !== undefined
|
const isControlled = isOpen !== undefined
|
||||||
const [openState, setOpenState] = useState(false)
|
const [openState, setOpenState] = useState(false)
|
||||||
|
|
||||||
|
if (isControlled && isOpen !== openState) setOpenState(isOpen)
|
||||||
|
|
||||||
const { select, isSelected, selected } = useSelect(options, value, {
|
const { select, isSelected, selected } = useSelect(options, value, {
|
||||||
multi,
|
multi,
|
||||||
onChange,
|
onChange,
|
||||||
@ -81,10 +83,6 @@ export const Dropdown: React.FC<DropdownProps> & {
|
|||||||
handleToggle(!openState)
|
handleToggle(!openState)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (disabled && openState && !isControlled) setOpenState(false)
|
|
||||||
}, [open, disabled, isControlled])
|
|
||||||
|
|
||||||
// Handle the controlled version of the component:
|
// Handle the controlled version of the component:
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
typeof isOpen !== 'undefined' && setOpenState(isOpen)
|
typeof isOpen !== 'undefined' && setOpenState(isOpen)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user