Skip to content

Commit 0954ec5

Browse files
authored
Fix maximum call stack size exceeded error on Tab component when using as={Fragment} (#1826)
1 parent df5b6a2 commit 0954ec5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
- Fix `ref` stealing from children ([#1820](https://github.com/tailwindlabs/headlessui/pull/1820))
4040
- Expose the `value` from the `Combobox` and `Listbox` components render prop ([#1822](https://github.com/tailwindlabs/headlessui/pull/1822))
4141
- Improve `scroll lock` on iOS ([#1824](https://github.com/tailwindlabs/headlessui/pull/1824))
42+
- Fix maximum call stack size exceeded error on `Tab` component when using `as={Fragment}` ([#1826](https://github.com/tailwindlabs/headlessui/pull/1826))
4243

4344
## [1.6.6] - 2022-07-07
4445

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ let TabRoot = forwardRefWithAs(function Tab<TTag extends ElementType = typeof DE
333333
let internalTabRef = useRef<HTMLElement | null>(null)
334334
let tabRef = useSyncRefs(internalTabRef, ref, (element) => {
335335
if (!element) return
336-
actions.forceRerender()
336+
requestAnimationFrame(() => actions.forceRerender())
337337
})
338338

339339
useIsoMorphicEffect(() => actions.registerTab(internalTabRef), [actions, internalTabRef])
@@ -490,7 +490,7 @@ let Panel = forwardRefWithAs(function Panel<TTag extends ElementType = typeof DE
490490
let internalPanelRef = useRef<HTMLElement>(null)
491491
let panelRef = useSyncRefs(internalPanelRef, ref, (element) => {
492492
if (!element) return
493-
actions.forceRerender()
493+
requestAnimationFrame(() => actions.forceRerender())
494494
})
495495

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

0 commit comments

Comments
 (0)