[Compiler Bug]: function outlining changes runtime semantics inside expressions #33138
Open
1 of 4 tasks
Labels
Component: React Compiler
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
Type: Bug
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAwhALYAOhCmOAFAJRHAA6xRMCOsxAPAGUcMPJgDmeNAE8iANwCGAGygIAvMADa7IjqL0mRVQD4WRAL6MAdDghCR4pgBptu-c2OmuPGMVbh5ACbyYAF+5swA1ER+fs4cOvQY2PiERGgQEAbA4URRMSBxunpJuATE6ZnM2RbWtsKiYk4uALpmAPRGANzsZiBmQA
Repro steps
() => { }
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
The text was updated successfully, but these errors were encountered: