Skip to content

Bug: React Compiler does not preserve HTML entity #35971

@mihkeleidast

Description

@mihkeleidast

When using React Compiler on this component:

export default function MyApp() {
  return (
    <div>
      &#32;
      <span>hello world</span>
    </div>
  );
}

the HTML entity gets removed with compiler:

import { c as _c } from "react/compiler-runtime";
export default function MyApp() {
  const $ = _c(1);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = (
      <div>
        <span>hello world</span>
      </div>
    );
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  return t0;
}

React version: 19.2.4

Steps To Reproduce

Link to code example: https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wAoAlPmAAdNvhgJcsNv3H5F+ADyEmANwB8CpYoBkAYgDMAJgDcO3crCYydTQAsElShHwB3HJULKA9DbttCUU-NS0dQQs6AF9xEAAaEDhWEiYAcxQQJgBbbDx8XE5MBBF8AAVKKDSmOgB5TGZWMHxo-BIYCGz8AHIAIzJe5wBaTErquiGpMkYh5NymSgQYXzUwXG6o8X4xCV9fOcwFska6dghiZHxREDIXa-FWsGOmMFSEZoqqmvqTsEiE8AOCDuACSdFwSzotzAKHIlDACGiQA

The current behavior

HTML entity is removed.

The expected behavior

HTML entity should be kept as-is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions