Passing the anchor as a ref #2605
Replies: 1 comment
-
Update: I'm working with passing the anchor element and referencing the button inside the HOC itself, works fine for now. const buttonRef = useRef<HTMLButtonElement | null>(null);
return (
<PopoverHUI className="relative" anchorRef={anchorRef}>
<PopoverHUI.Button as="div" ref={buttonRef}>{anchorEl}</PopoverHUI.Button>
<PopoverHUI.Panel className="absolute z-10">
{children}
</PopoverHUI.Panel>
</PopoverHUI>
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I would like to make a HOC out of Popover and currently got it working by passing both the ButtonEl and PanelEl as ReactNodes and rendering them in their appropriate place. However, I would like to instead of passing the ButtonEl as a ReactNode do it as a reference with useRef. The reason being I could then get the ref objects' width and height etc...
Something like this:
I know it can be done using react-popper but would like a more vanilla way. Any suggestions on how to go about this?
Beta Was this translation helpful? Give feedback.
All reactions