diff --git a/packages/react/components/Popover.tsx b/packages/react/components/Popover.tsx index 80de2b6..15a7531 100644 --- a/packages/react/components/Popover.tsx +++ b/packages/react/components/Popover.tsx @@ -26,14 +26,20 @@ interface PopoverProps extends AsChild { } const Popover = ({ children, opened, asChild }: PopoverProps) => { - const state = React.useState({ + const [state, setState] = React.useState({ opened: opened ?? false, }); + useEffect(() => { + if (opened !== undefined) { + setState((p) => ({ ...p, opened: opened })); + } + }, [opened]); + const Comp = asChild ? Slot : "div"; return ( - + {children} );