What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAYhBABTBED6AQgIYxEC+yR19T7ASgg7gB0AYQgBbAA6EEmHABUAnhISsAlBwA6xIjAQ5YxClqImiAHi4wAfMdMngFdQF4r5gCZ4AbkQD0VlrYmZj6WNtqqANxaAZggADQgcIRoeADmKCDAtj4+SZJ4ADYM+IQAshBuCOwaIAwFBTXR8eAAFhAA7gCSsggwmHVgKDgwUAgsQA
Repro steps
The following code:
function Foo({ _Bar }: { _Bar: React.ComponentType }) {
return (
<_Bar>
{() => <div />}
</_Bar>
);
}
is compiled to the following:
import { c as _c } from "react/compiler-runtime";
function Foo(t0) {
const $ = _c(1);
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <_Bar>{_temp}</_Bar>;
$[0] = t1;
} else {
t1 = $[0];
}
return t1;
}
function _temp() {
return <div />;
}
It appears the the compiler makes an assumption that anything prefixed with _ is a host / built-on component here. The _-prefix is admittedly an unconventional naming choice, but it's valid JavaScript and worked fine before React Compiler. The breakage is silent and surprising: React's convention is that lowercase tags are host components, a leading underscore followed by a capital letter is not lowercase, so a reader (and the JSX runtime) reasonably reads <_Bar> as a component, not a host element. The compiler diverges from that expectation.
The fix was trivia and required an alias:
function Foo({ _Bar: Bar }: { _Bar: React.ComponentType }) {
return (
<Bar>
{() => <div />}
</Bar>
);
}
How often does this bug happen?
Every time
What version of React are you using?
19.2.3
What version of React Compiler are you using?
1.0.0
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAYhBABTBED6AQgIYxEC+yR19T7ASgg7gB0AYQgBbAA6EEmHABUAnhISsAlBwA6xIjAQ5YxClqImiAHi4wAfMdMngFdQF4r5gCZ4AbkQD0VlrYmZj6WNtqqANxaAZggADQgcIRoeADmKCDAtj4+SZJ4ADYM+IQAshBuCOwaIAwFBTXR8eAAFhAA7gCSsggwmHVgKDgwUAgsQA
Repro steps
The following code:
is compiled to the following:
It appears the the compiler makes an assumption that anything prefixed with
_is a host / built-on component here. The_-prefix is admittedly an unconventional naming choice, but it's valid JavaScript and worked fine before React Compiler. The breakage is silent and surprising: React's convention is that lowercase tags are host components, a leading underscore followed by a capital letter is not lowercase, so a reader (and the JSX runtime) reasonably reads<_Bar>as a component, not a host element. The compiler diverges from that expectation.The fix was trivia and required an alias:
How often does this bug happen?
Every time
What version of React are you using?
19.2.3
What version of React Compiler are you using?
1.0.0