fix: componentcreator: avoid wrapping children in array for createelement (#552)#945
Open
frano-m wants to merge 1 commit into
Open
fix: componentcreator: avoid wrapping children in array for createelement (#552)#945frano-m wants to merge 1 commit into
frano-m wants to merge 1 commit into
Conversation
…ment (#552) 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: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes how ComponentCreator passes children into React.createElement to avoid React treating a single child as a keyed “list” (and the resulting warnings in wrappers like MUI Tooltip and components that don’t accept children).
Changes:
- Stop wrapping the
childrenargument in a one-element array when callingReact.createElement. - Pass
children(orprops.children) directly as the third argument tocreateElement, preserving expected behavior for single-child and array-children cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ComponentCreatorpreviously passed children toReact.createElementwrapped in a one-element array literal. React treats an array third-arg as a "list" of children and requires akeyon each item, which surfaces as the "Each child in a list should have a unique 'key' prop" warning from any wrapping component (MUITooltipis a common one), and as a "prop children is not supported" prop-type warning on components that don't accept children (e.g.MuiChip).createElementinstead. Behavior is unchanged for view builders that return a single child (the common case); view builders that return an array continue to work because React still treats arrays as lists either way.Test plan
npm run check-format— cleannpm run lint— cleannpm run test-compile— cleannpm test— 447/447AzulFileDownloadref-forwarding, tracked in AzulFileDownload: forward ref so it can be used as a Tooltip child without a span wrapper #944.)Closes #552
🤖 Generated with Claude Code