Skip to content

Commit e26e287

Browse files
sserrataclaude
andcommitted
refactor: remove unnecessary cloneElement in non-lazy TabContent
With TabItem now self-managing visibility via context, the cloneElement call that only injected key was dead weight. Render children directly instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 28734f5 commit e26e287

6 files changed

Lines changed: 6 additions & 52 deletions

File tree

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,7 @@ function TabContent({
209209
return cloneElement(selectedTabItem, { className: "margin-top--md" });
210210
}
211211
return (
212-
<div className="margin-top--md openapi-tabs__code-content">
213-
{childTabs.map((tabItem, i) =>
214-
cloneElement(tabItem, {
215-
key: i,
216-
})
217-
)}
218-
</div>
212+
<div className="margin-top--md openapi-tabs__code-content">{childTabs}</div>
219213
);
220214
}
221215

packages/docusaurus-theme-openapi-docs/src/theme/ApiTabs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,7 @@ function TabContent({
210210
}
211211
return cloneElement(selectedTabItem, { className: "margin-top--md" });
212212
}
213-
return (
214-
<div className="margin-top--md">
215-
{childTabs.map((tabItem, i) =>
216-
cloneElement(tabItem, {
217-
key: i,
218-
})
219-
)}
220-
</div>
221-
);
213+
return <div className="margin-top--md">{childTabs}</div>;
222214
}
223215
function TabsComponent(props: TabListProps): React.JSX.Element {
224216
const tabs = useTabsContextValue(props);

packages/docusaurus-theme-openapi-docs/src/theme/DiscriminatorTabs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,7 @@ function TabContent({
189189
}
190190
return cloneElement(selectedTabItem, { className: "margin-top--md" });
191191
}
192-
return (
193-
<div className="margin-top--md">
194-
{childTabs.map((tabItem, i) =>
195-
cloneElement(tabItem, {
196-
key: i,
197-
})
198-
)}
199-
</div>
200-
);
192+
return <div className="margin-top--md">{childTabs}</div>;
201193
}
202194
function TabsComponent(props: TabProps): React.JSX.Element {
203195
const tabs = useTabsContextValue(props);

packages/docusaurus-theme-openapi-docs/src/theme/MimeTabs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,7 @@ function TabContent({
225225
}
226226
return cloneElement(selectedTabItem, { className: "margin-top--md" });
227227
}
228-
return (
229-
<div className="margin-top--md">
230-
{childTabs.map((tabItem, i) =>
231-
cloneElement(tabItem, {
232-
key: i,
233-
})
234-
)}
235-
</div>
236-
);
228+
return <div className="margin-top--md">{childTabs}</div>;
237229
}
238230
function TabsComponent(props: Props & TabProps): React.JSX.Element {
239231
const tabs = useTabsContextValue(props);

packages/docusaurus-theme-openapi-docs/src/theme/OperationTabs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,7 @@ function TabContent({
187187
}
188188
return cloneElement(selectedTabItem, { className: "margin-top--md" });
189189
}
190-
return (
191-
<div className="margin-top--md">
192-
{childTabs.map((tabItem, i) =>
193-
cloneElement(tabItem, {
194-
key: i,
195-
})
196-
)}
197-
</div>
198-
);
190+
return <div className="margin-top--md">{childTabs}</div>;
199191
}
200192
function TabsComponent(props: TabProps): React.JSX.Element {
201193
const tabs = useTabsContextValue(props);

packages/docusaurus-theme-openapi-docs/src/theme/SchemaTabs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,7 @@ function TabContent({
204204
}
205205
return cloneElement(selectedTabItem, { className: "margin-top--md" });
206206
}
207-
return (
208-
<div className="margin-top--md">
209-
{childTabs.map((tabItem, i) =>
210-
cloneElement(tabItem, {
211-
key: i,
212-
})
213-
)}
214-
</div>
215-
);
207+
return <div className="margin-top--md">{childTabs}</div>;
216208
}
217209
function TabsComponent(props: SchemaTabsProps): React.JSX.Element {
218210
const tabs = useTabsContextValue(props);

0 commit comments

Comments
 (0)