-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
[React 19] React Compiler doesn't preserve HTML Entities #29100
Comments
To address the issue with React Compiler not preserving HTML entities, you can use a different approach to ensure that the > character is correctly rendered in your JSX. Instead of using the HTML entity >, you can use JavaScript's String.fromCharCode method to represent the character in a way that avoids the issue. |
I think export default function MyApp() {
return <div>Parent {">"} Children</div>;
} |
That seems like a nice workaround, thank you! |
Thanks for the heads up, we’ll fix! |
Babel doesn't seem to properly preserve escaping of HTML entities when emitting JSX text children, so this commit works around the issue by emitting a JsxExpressionContainer for JSX children that contain ">", "<", or "&" characters. Closes #29100 [ghstack-poisoned]
Babel doesn't seem to properly preserve escaping of HTML entities when emitting JSX text children, so this commit works around the issue by emitting a JsxExpressionContainer for JSX children that contain ">", "<", or "&" characters. Closes #29100 ghstack-source-id: 2d0622397cc067c6336f3635073e07daef854084 Pull Request resolved: #29143
Fixed, thanks for reporting! |
Summary
When using React Compiler, this component:
becomes
which leads to this error:
ERROR: The character ">" is not valid inside a JSX element
Repro: https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wAoAlPmAAdNvhgJcsNgB5CTAG4A+AApkpdAgDIA5rgDc+AMIALJpUJa5AekWrD4gL7iQzoA
The text was updated successfully, but these errors were encountered: