Skip to content

Commit

Permalink
Make sure panels re-register when IDs are calculated in React < 18 (#…
Browse files Browse the repository at this point in the history
…2883)

* Make sure panels re-register when IDs are calculated in React < 18

* Update changelog

* Add comment
  • Loading branch information
thecrypticace committed Apr 12, 2024
1 parent b2300ca commit 2b161b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `immediate` prop to `<Combobox />` for immediately opening the Combobox when the `input` receives focus ([#2686](https://github.com/tailwindlabs/headlessui/pull/2686))
- Add `virtual` prop to `Combobox` component ([#2779](https://github.com/tailwindlabs/headlessui/pull/2779))

### Fixed

- Make sure panels re-register when IDs are calculated in React < 18 ([#2883](https://github.com/tailwindlabs/headlessui/pull/2883))

## [1.7.18] - 2024-01-08

### Fixed
Expand Down
12 changes: 11 additions & 1 deletion packages/@headlessui-react/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,17 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
let internalPanelRef = useRef<HTMLElement | null>(null)
let panelRef = useSyncRefs(internalPanelRef, ref)

useIsoMorphicEffect(() => actions.registerPanel(internalPanelRef), [actions, internalPanelRef])
useIsoMorphicEffect(
() => actions.registerPanel(internalPanelRef),
[
actions,
internalPanelRef,

// The `id` prop is here to force a re-render of the
// corresponding `Tab` whenever the `id` is calculated in React < 18
id,
]
)

let mySSRIndex = useStableCollectionIndex('panels')

Expand Down

0 comments on commit 2b161b3

Please sign in to comment.