Skip to content

Support passing ref on children #212

@neoncube2

Description

@neoncube2

I just spent half a day trying to figure out why my ref wasn't working, because I had it on the inner element instead of on <Popover>, haha XD

e.g., I had this:

<Popover
  ...
>
  <button ref={(newRef) => console.log(newRef)}>
    test
  </button>
</Popover>

But needed this:

<Popover
  ref={(newRef) => console.log(newRef)}
  ...
>
  <button>
    test
  </button>
</Popover>

I think it'd be nice if ref were supported in either place. It looks like this would be as easy as just modifying this line of code in Popover.tsx so that it merges any existing ref attributes:

const renderChild = () => cloneElement(children, { ref: handleRef });

I'd be happy to try to provide a PR, if you like; just let me know :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions