Commit 9dc83e0
authored
This PR fixes an issue in React 19 where a warning is shown in the
console:
```
Invalid prop `data-headlessui-state` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.
```
This PR fixes that by doing 2 things:
1. We make sure that we properly check for `Fragment`. We were relying
on identity, but will now also check the underlying symbol.
2. Make sure that the element we forward props to is not a `Fragment`
either.
## Test plan
- All existing tests still pass (this codebase is using React 18 instead
of 19,
where we can't reproduce the warning)
- Tested in a reproduction repo with React 19 that the warning is gone.
Before:
<img width="1190" height="849" alt="image"
src="https://github.com/user-attachments/assets/c2fd061c-4b6b-4685-a59c-c0edc6eb8642"
/>
After:
<img width="1190" height="849" alt="image"
src="https://github.com/user-attachments/assets/ee8318b6-06fa-4fa7-84bf-b96af3a34f87"
/>
Fixes: #3597
Fixes: #3351
1 parent c9bf352 commit 9dc83e0
File tree
4 files changed
+18
-8
lines changed- packages/@headlessui-react
- src
- components
- disclosure
- transition
- utils
4 files changed
+18
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 192 | + | |
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | | - | |
274 | | - | |
| 274 | + | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
0 commit comments