Open
Description
What kind of issue is this?
- React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
- babel-plugin-react-compiler (build issue installing or using the Babel plugin)
- eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
function Component() {
return <Stringify value={[
(() => { }).toString(),
(() => { }) + "",
(function foo() { }) + "",
(function foo() { }).toString(),
]}/>;
}
() => { }
gets outlined to a temp global function, which results in a different toString value:
(() => { return "sadasd" }) + ""
->'() => { return "sadasd" }'
(function _temp2() { return "sadasd"; }).toString()
->'function _temp2() {\n return "sadasd";\n}'
Same probably happens to components that take functions as props and apply .toString()
on them for whatever reason.
May not be a bug depending on how react defines this case. I think the only way of fixing this is not to outline lambdas in expressions. But I think this breaks the intended optimization entirely, so this might be just defined as an intended incompability.
How often does this bug happen?
Every time
What version of React are you using?
19
What version of React Compiler are you using?
rc1