Skip to content

How to manually control the Popover Component? #1311

Answered by mshwery
jkobjacob asked this question in Q&A
Discussion options

You must be logged in to vote

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 the ref value to the component you want to act as the trigger:

  <Popover content={YourPopoverContent}>
    {({ isShown, toggle, getRef }) => (
      <IconButton
        ref={getRef}
        icon={MoreIcon}
        appearance="minimal"
        isActive={isShown}
        onClick={toggle}
      />
    )}
  </Popover>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jkobjacob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants