-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maximum update depth exceeded" when rendering <MenuButton> as Fragment #3476
Comments
…, `DisclosureButton` or `Button` components (#3478) This PR fixes an issue where a maximum update depth exceeded error was thrown when using `as={Fragment}` on button related components. The issue here is that the `ref` on a element would re-fire every render _if_ the a function was used _and_ the function is a new function (aka not a stable function). This resulted in the `ref` being called with the DOM element, then `null`, then the DOM element, then `null`, and so on. To solve this, we have to make sure that the `ref` is always a stable reference. Fixes: #3476 Fixes: #3439
Hey! This should be fixed by #3478, and is available in the latest release (2.1.8). You can already try it using:
|
@RobinMalfait there's another edge case I found related to this I believe, here's a video https://youtu.be/wVMtqbnkF4o Notice when I open and close the menu, everything is fine. When it's open however, it expands the scrollable area. If I scroll to this "new" area and then close the menu, the error occurs. This is an edge case because it happens only when the scroll area expands as far as I can tell. This issue has existed for a long time too, it's not specific to 2.1.8. |
This "feature" still exists in the @latest (2.2.0). Rendering Menu Items as fragment still results in "maximum update length". If I roll back from 2.2.0 to 1.7.19, error goes away. When I "click" menu item button re-render throws error. `import { Menu, Transition } from "@headlessui/react"; export default function MessageOptionsDropdown({ message }) {
} |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v2.1.7
What browser are you using?
Chrome
Describe your issue
This issue appears to be triggered when the MenuButton is wrapped in a Fragment.
The text was updated successfully, but these errors were encountered: