Skip to content

Commit c5df54e

Browse files
committed
fix(tabs): avoid to set props to fragments
1 parent 2893603 commit c5df54e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/fractal/src/utils.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
type ReactNode,
33
Children,
44
cloneElement,
5+
Fragment,
56
isValidElement,
67
JSXElementConstructor,
78
} from 'react'
@@ -86,7 +87,19 @@ export function extendChildren(
8687
props: (childProps: Record<string, unknown>) => Record<string, unknown>,
8788
displayName?: string,
8889
): ReactNode {
89-
return Children.map(children, (child) => {
90+
let childrenToIterateOver = children
91+
if (Children.count(children) === 0) {
92+
return children
93+
}
94+
if (
95+
Children.count(children) === 1 &&
96+
isValidElement(children) &&
97+
children.type === Fragment
98+
) {
99+
childrenToIterateOver = children.props.children as ReactNode
100+
}
101+
102+
return Children.map(childrenToIterateOver, (child) => {
90103
if (!isValidElement(child)) {
91104
return child
92105
}

0 commit comments

Comments
 (0)