Skip to content

Commit 2b161b3

Browse files
Make sure panels re-register when IDs are calculated in React < 18 (#2883)
* Make sure panels re-register when IDs are calculated in React < 18 * Update changelog * Add comment
1 parent b2300ca commit 2b161b3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Add `immediate` prop to `<Combobox />` for immediately opening the Combobox when the `input` receives focus ([#2686](https://github.com/tailwindlabs/headlessui/pull/2686))
1313
- Add `virtual` prop to `Combobox` component ([#2779](https://github.com/tailwindlabs/headlessui/pull/2779))
1414

15+
### Fixed
16+
17+
- Make sure panels re-register when IDs are calculated in React < 18 ([#2883](https://github.com/tailwindlabs/headlessui/pull/2883))
18+
1519
## [1.7.18] - 2024-01-08
1620

1721
### Fixed

packages/@headlessui-react/src/components/tabs/tabs.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,17 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
566566
let internalPanelRef = useRef<HTMLElement | null>(null)
567567
let panelRef = useSyncRefs(internalPanelRef, ref)
568568

569-
useIsoMorphicEffect(() => actions.registerPanel(internalPanelRef), [actions, internalPanelRef])
569+
useIsoMorphicEffect(
570+
() => actions.registerPanel(internalPanelRef),
571+
[
572+
actions,
573+
internalPanelRef,
574+
575+
// The `id` prop is here to force a re-render of the
576+
// corresponding `Tab` whenever the `id` is calculated in React < 18
577+
id,
578+
]
579+
)
570580

571581
let mySSRIndex = useStableCollectionIndex('panels')
572582

0 commit comments

Comments
 (0)