-
Hi, Can someone provide me with an example on how to manually control the Popover component? I'm passing the below function as the child to the Popover as per the documentation.
But still i have no clue on how to use these. I tried calling toggle inside the body conditionally based on state of its parent component and i just blowed up the stack. So, when and how to use these values in the function body? And also if we pass a function as its child, which element is the target around which Popover is positioned? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The children-as-a-function approach is a means of passing the popover state and functions down to child components. If you use a function, you need to pass <Popover content={YourPopoverContent}>
{({ isShown, toggle, getRef }) => (
<IconButton
ref={getRef}
icon={MoreIcon}
appearance="minimal"
isActive={isShown}
onClick={toggle}
/>
)}
</Popover> |
Beta Was this translation helpful? Give feedback.
The children-as-a-function approach is a means of passing the popover state and functions down to child components.
isShown
is simply there to read whether or not the popover is shown.If you use a function, you need to pass
getRef
as theref
value to the component you want to act as the trigger: