Skip to content

Commit 3324d77

Browse files
frano-mclaude
andauthored
fix: componentcreator: avoid wrapping children in array for createelement (#552) (#945)
react.createelement treats a literal array passed as the third argument as a list of children, requiring a key on each item. when c.component is a tooltip or any element that renders its children, this surfaces as a "each child in a list should have a unique key prop" warning, and components that don't accept children (e.g. muichip) issue a "prop children is not supported" prop-type warning. pass the single child value directly instead of wrapping it in a one-element array literal. behavior is unchanged for viewbuilders that return a single child (the common case); viewbuilders that already return an array continue to work as react still treats arrays as lists either way. Co-authored-by: Fran McDade <18710366+frano-m@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 42b73de commit 3324d77

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/components/ComponentCreator/ComponentCreator.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ export const ComponentCreator = <T,>({
6363
systemStatus,
6464
})
6565
: {};
66-
return createElement(c.component, { ...c.props, ...props, key: k }, [
66+
return createElement(
67+
c.component,
68+
{ ...c.props, ...props, key: k },
6769
children ?? props.children,
68-
]);
70+
);
6971
})}
7072
</>
7173
);

0 commit comments

Comments
 (0)