Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with single prop added in spread with binary conditional when used with legacy JSX transform in dev env #29925

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

undeletable
Copy link

Summary

The PR fixes #29902
Wrapping part of createElement() function with additional check if config argument value is an object. This check makes sense, because the wrapped code assumes that config is an object, referring to its properties and using in operator for that.
With the following kind of code:

<button
    {...(isCountButtonActive && {
      onClick: () => setCount(currentCount => currentCount + 1)
    })}
>
    Increment count
</button>

config is false if isCountButtonActive === false, so that produces JS error mentioned in the issue. It's fixed by the above-mentioned check.

How did you test this change?

I've built react packages with my changes, replaced them in node_modules folder of https://github.com/undeletable/jsx-spread-with-react-19-rc app (app using legacy JSX transform; the code above is from there) and ran that app in dev mode.

Before the changes:
react-spread-issue

Same app after the changes:
react-spread-issue-fixed

Copy link

vercel bot commented Jun 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 10:50am

@react-sizebot
Copy link

react-sizebot commented Jun 18, 2024

Comparing: b3aface...6a39b01

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.16% 1.82 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.99 kB 497.99 kB = 89.27 kB 89.27 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.81 kB 502.81 kB = 89.97 kB 89.97 kB
facebook-www/ReactDOM-prod.classic.js = 597.08 kB 597.08 kB = 105.33 kB 105.34 kB
facebook-www/ReactDOM-prod.modern.js = 571.42 kB 571.42 kB = 101.27 kB 101.27 kB
test_utils/ReactAllWarnings.js Deleted 62.88 kB 0.00 kB Deleted 15.69 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-rc/react/cjs/react.react-server.production.js +0.23% 13.28 kB 13.31 kB +0.27% 3.66 kB 3.67 kB
oss-stable-semver/react/cjs/react.react-server.production.js +0.23% 13.28 kB 13.31 kB +0.27% 3.66 kB 3.67 kB
oss-stable/react/cjs/react.react-server.production.js +0.23% 13.30 kB 13.33 kB +0.33% 3.68 kB 3.69 kB
test_utils/ReactAllWarnings.js Deleted 62.88 kB 0.00 kB Deleted 15.69 kB 0.00 kB

Generated by 🚫 dangerJS against 6a39b01

@undeletable undeletable changed the title Fix case of using single prop in spread with binary conditional with legacy JSX transform in dev env Fix issue with single prop added in spread with binary conditional when used with legacy JSX transform in dev env Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants