fix(@emotion/primitives-core): skip style and ref when finalTag is React.Fragment#3378
fix(@emotion/primitives-core): skip style and ref when finalTag is React.Fragment#3378phthhieu wants to merge 1 commit into
Conversation
…act.Fragment
React.Fragment only accepts `key` and `children` props. When a styled
component resolves to React.Fragment (via `styled(React.Fragment)` or
the `as={React.Fragment}` prop), the unconditional `newProps.style`
assignment would pass an invalid `style` prop to the Fragment. React
Native 0.81+ added strict validation that surfaces this as an error.
Guard the style and ref assignments behind `finalTag !== React.Fragment`
to avoid forwarding unsupported props.
Fixes emotion-js#3359
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
Note on CI failures: The These are pre-existing on |
What:
Prevent
styleandrefprops from being forwarded toReact.Fragmentinside@emotion/primitives-core's styled component render path.Why:
React.Fragmentonly acceptskeyandchildrenas props. When a styled component resolves toReact.Fragment— either viastyled(React.Fragment)\...`or theas={React.Fragment}shorthand — the code increateStyledunconditionally assignednewProps.style = [computedStyles, props.style]before callingReact.createElement(finalTag, newProps). This passed an invalidstyle` prop to the Fragment.React Native 0.81+ (and React Native 0.78+ per some reports) added strict prop validation that surfaces this as a runtime error:
Fixes #3359.
How:
Guard the
styleandrefassignments withif (finalTag !== React.Fragment)so those props are only added when the target element is capable of accepting them.Checklist:
🤖 Generated with Claude Code | Session: ffa7459a-75f5-425f-8eb4-d23918b2eaf9