Skip to content

Conversation

@hlysine
Copy link

@hlysine hlysine commented Jan 18, 2026

Summary

Fixes #35379

The React compiler currently emits code that produces a runtime error when the global Symbol is being shadowed by another reference named Symbol. This PR changes the emitted code to access Symbol via globalThis.Symbol to fix this issue.

Thanks to #35429 for providing a hint to the fix, but this PR also applies the fix to PropagateEarlyReturns and InlineJsxTransform.

How did you test this change?

All related test fixtures are updated with this change. Some examples of the generated code:

- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
+ if ($[0] === globalThis.Symbol.for("react.memo_cache_sentinel")) {
   if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.cond) {
-    t0 = Symbol.for("react.early_return_sentinel");
+    t0 = globalThis.Symbol.for("react.early_return_sentinel");
     bb0: {

@meta-cla meta-cla bot added the CLA Signed label Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React Compiler generates erroneous code when an app contains a component named Symbol

1 participant