[React-ARIA] - Maximum update depth exceeded while building popover component with render props #2450
-
I'm stumped! Looking for a little help here, not sure if I'm doing something wrong, or if this is a bug. I'm trying to build a flexible Popover component by using the example for useOverlayTrigger as a jumping-off point. I am trying to make this a flexible component for other developers on my team and I'm attempting to use the render-props pattern so that other developers don't have to worry about hooking up all the React-ARIA stuff in order to use the Popover. Here's a simplified reproduction in CodeSandbox. Upon clicking the popover trigger, I see: One way to clear the error (for debugging purposes) is to not attach the popoverRef by commenting out line 60. The popover will then correctly render, though I'm assuming we also lose a lot of React-ARIA functionality so it isn't a real fix.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 18 replies
-
I think if you are seeing it fixed when you do not attach a popoverRef, then you are causing something where the actual node that popoverRef is attached to keeps changing. It's a bit hard to follow all of the render props around, but you can see that you're generating a new node constantly if you put this line of code into your PopoverWithTrigger just after the
I did chase it down to this effect https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/useOverlayPosition.ts#L126, which has a dep on the triggerRef.current |
Beta Was this translation helpful? Give feedback.
I think if you are seeing it fixed when you do not attach a popoverRef, then you are causing something where the actual node that popoverRef is attached to keeps changing. It's a bit hard to follow all of the render props around, but you can see that you're generating a new node constantly if you put this line of code into your PopoverWithTrigger just after the
useOverlayTrigger
…