Skip to content

fix: preserve explicitly passed undefined props - #5683

Merged
quantizor merged 1 commit into
mainfrom
fix/undefined-props-passthrough
Mar 19, 2026
Merged

quantizor merged 1 commit into
mainfrom
fix/undefined-props-passthrough

Conversation

@quantizor

Copy link
Copy Markdown
Contributor

Summary

  • Only strip undefined values that came from .attrs() (to enable removing props via attrs)
  • Explicitly passed undefined props are now preserved, fixing compatibility with libraries like MUI and Radix UI that pass undefined to reset inherited defaults (e.g., role={undefined})

Test plan

  • All 501 web tests pass (including existing attrs removal tests)
  • Manual test with MUI ButtonBase role={undefined} pattern

Closes #4338

@changeset-bot

changeset-bot Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8bdb9a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
styled-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

When a user explicitly passes a prop as undefined (e.g., role={undefined}),
attrs no longer overwrites it. This allows resetting inherited defaults,
fixing compatibility with libraries like MUI and Radix UI.

Props set to undefined via .attrs() without an explicit user prop are
still stripped as before.

Closes #4338
@quantizor
quantizor force-pushed the fix/undefined-props-passthrough branch from 8522983 to 8bdb9a3 Compare March 19, 2026 05:34
@quantizor
quantizor marked this pull request as ready for review March 19, 2026 05:38
@quantizor
quantizor merged commit a777f5a into main Mar 19, 2026
5 checks passed
@quantizor
quantizor deleted the fix/undefined-props-passthrough branch March 19, 2026 05:38
quantizor added a commit that referenced this pull request May 9, 2026
ContainerPublisher (the wrapper mounted when `$containerName` is set)
used to mutate the cached `elementProps.onLayout` in place, so each
full-cache-hit re-render wrapped the previously-composed handler again.
After N re-renders, the user's onLayout fired N+1 times per layout
event. Clone the props object before assigning the composed handler.

Native `resolveContext` was missing the explicit-`undefined`-overrides-
attrs guard that web has had since #5683. Mirror the web check so
`<Comp prop={undefined} />` opts out of an attrs-provided default.

`parseMediaQuery` cached parsed Query results in an unbounded `Map`;
long-lived sessions that interpolated runtime variation (`@media
(min-width: ${px}px)`) would leak. Switch to the same FIFO-evicting
discipline the parser uses for its other per-string caches.

Wrap the RSC compiler/plugin override slot in `React.cache` so true
Flight rendering scopes the slot per request rather than process-wide.
The pre-existing `__resetRSCOverrideForTesting` shim still works for
non-Flight test setups (regular `renderToString` doesn't activate
`React.cache`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Pass on undefined props to final component

1 participant