diff --git a/packages/@headlessui-react/src/components/tabs/tabs.test.tsx b/packages/@headlessui-react/src/components/tabs/tabs.test.tsx
index 20e16bfa46..002f564ecb 100644
--- a/packages/@headlessui-react/src/components/tabs/tabs.test.tsx
+++ b/packages/@headlessui-react/src/components/tabs/tabs.test.tsx
@@ -168,6 +168,56 @@ describe('Rendering', () => {
)
describe('`renderProps`', () => {
+ it(
+ 'should be possible to render using as={Fragment}',
+ suppressConsoleLogs(async () => {
+ render(
+
+
+
+
+
+ Tab 2
+ Tab 3
+
+
+
+ Content 1
+ Content 2
+ Content 3
+
+
+ )
+
+ assertTabs({ active: 0, tabContents: 'Tab 1', panelContents: 'Content 1' })
+ })
+ )
+
+ it(
+ 'should be possible to render using multiple as={Fragment}',
+ suppressConsoleLogs(async () => {
+ render(
+
+
+
+
+
+
+
+
+
+
+
+ Content 1
+ Content 2
+
+
+ )
+
+ assertTabs({ active: 0, tabContents: 'Tab 1', panelContents: 'Content 1' })
+ })
+ )
+
it(
'should expose the `selectedIndex` on the `Tab.Group` component',
suppressConsoleLogs(async () => {
diff --git a/packages/@headlessui-react/src/components/tabs/tabs.tsx b/packages/@headlessui-react/src/components/tabs/tabs.tsx
index a34ce3dc97..7b8ec5f014 100644
--- a/packages/@headlessui-react/src/components/tabs/tabs.tsx
+++ b/packages/@headlessui-react/src/components/tabs/tabs.tsx
@@ -44,8 +44,6 @@ enum ActionTypes {
RegisterPanel,
UnregisterPanel,
-
- ForceRerender,
}
type Actions =
@@ -54,7 +52,6 @@ type Actions =
| { type: ActionTypes.UnregisterTab; tab: MutableRefObject }
| { type: ActionTypes.RegisterPanel; panel: MutableRefObject }
| { type: ActionTypes.UnregisterPanel; panel: MutableRefObject }
- | { type: ActionTypes.ForceRerender }
let reducers: {
[P in ActionTypes]: (
@@ -110,9 +107,6 @@ let reducers: {
[ActionTypes.UnregisterPanel](state, action) {
return { ...state, panels: state.panels.filter((panel) => panel !== action.panel) }
},
- [ActionTypes.ForceRerender](state) {
- return { ...state }
- },
}
let TabsSSRContext = createContext | null>(
@@ -154,7 +148,6 @@ let TabsActionsContext = createContext<{
registerTab(tab: MutableRefObject): () => void
registerPanel(panel: MutableRefObject): () => void
change(index: number): void
- forceRerender(): void
} | null>(null)
TabsActionsContext.displayName = 'TabsActionsContext'
@@ -229,9 +222,6 @@ let Tabs = forwardRefWithAs(function Tabs dispatch({ type: ActionTypes.UnregisterPanel, panel })
},
- forceRerender() {
- dispatch({ type: ActionTypes.ForceRerender })
- },
change(index: number) {
if (realSelectedIndex.current !== index) {
onChangeRef.current(index)
@@ -335,10 +325,7 @@ let TabRoot = forwardRefWithAs(function Tab(null)
- let tabRef = useSyncRefs(internalTabRef, ref, (element) => {
- if (!element) return
- requestAnimationFrame(() => actions.forceRerender())
- })
+ let tabRef = useSyncRefs(internalTabRef, ref)
useIsoMorphicEffect(() => actions.registerTab(internalTabRef), [actions, internalTabRef])
@@ -492,10 +479,7 @@ let Panel = forwardRefWithAs(function Panel(null)
- let panelRef = useSyncRefs(internalPanelRef, ref, (element) => {
- if (!element) return
- requestAnimationFrame(() => actions.forceRerender())
- })
+ let panelRef = useSyncRefs(internalPanelRef, ref)
useIsoMorphicEffect(() => actions.registerPanel(internalPanelRef), [actions, internalPanelRef])