headlessui: "Invalid prop `data-headlessui-state` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props."
What package within Headless UI are you using?
"@headlessui/react": "0.0.0-insiders.fbad6a9",
What browser are you using?
For example: Chrome
Reproduction URL
I was not able to create a minimal reproduction, yet. Will update once I have one. Wanted to share the issue now so others can search for it and help.
Describe your issue
I am testing React 19, Next 15, React Compiler in our Project. When rendering our app I am getting multiple console errors in the browser like…
Warning: Invalid prop `data-headlessui-state` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.
at c (webpack-internal:///(app-pages-browser)/./node_modules/@headlessui/react/dist/internal/open-closed.js:17:18)
at u (webpack-internal:///(app-pages-browser)/./node_modules/@headlessui/react/dist/internal/close-provider.js:13:18)
at me (webpack-internal:///(app-pages-browser)/./node_modules/@headlessui/react/dist/components/disclosure/disclosure.js:111:24)
at SelectDatasets (webpack-internal:///(app-pages-browser)/./src/app/regionen/[regionSlug]/_components/SidebarLayerControls/StaticDatasets/SelectDatasets.tsx:32:72)
at nav
…
I am seeing the same error with other libraries, so this might be a temporary or a new issue with React 19 or Next 15 or React Compiler.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 13
- Comments: 20 (3 by maintainers)
Commits related to this issue
- Fix console error https://github.com/tailwindlabs/headlessui/issues/3351 — committed to rfui-library/rfui-package by adamzerner 2 years ago
- Multiselect (#17) * WIP * Use small checkbox * Allow `xs` size for `Checkbox` * Deal with `size` * Use `readOnly` * Update display text * Get controlled working * Handle `defaultValue` for `mu... — committed to rfui-library/rfui-package by adamzerner 2 years ago
Same issue happening in React 19 RC
Solution that worked for me is to add the
as="div"prop to the<Disclosure />component like this:<Disclosure {...rest} as="div">Happening in React 19 with Vite 6, happening in
Listbox. Usingas="div"resolved the issue, but Idk whether there’s any side effectGot it: https://stackblitz.com/edit/vitejs-vite-x9bjfwzm?file=src%2Fmain.tsx
I simplified it down from this file.
The fragment here in minimal form is pointless, but in practice the point is to do this:
This can be mitigated by replacing the fragment with
<div>withdisplay: contentsstyleHappening with React 19 and Next 15.1.6 when using Menu. Using
as="div"resolved the issue. Any updates if this gets fixed?Hey!
Can anyone running into this issue provide a minimal reproduction repo? Inside of Headless UI we check whether a
Fragmentwas used or not. Only thing I can think of is that there is a different instance ofFragment, but looking at the React Compiler it seems like they just useFragmentfrom thereactpackage directly.Would love to get it fixed, so if anyone can share a reproduction that will be greatly appreciated.
This is happening to me in
"react": 18.3.1not 19… just wanted to share. And we’re not using theDisclosurecomponent.