### What kind of issue is this? - [x] 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 https://playground.react.dev/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCAyhBgngBZoB2A5gDQEAmEl1djTBAXwIAzGFQIBySNQC0AGzQAjCQG4AOgw1wIDMIVIIAwqTxUAEhAgBrAgF4CACgBuAQzlQEASjsA+IhoICbV1Cdhc8FzsiAld3BEF1TQZAmBpYZOAAwIIsMSwARmQSMm4aemYHYjCIwU8WLMDciCwAJiLOUt4KqvDIgU8sgUShjQ0EAA8cfGiDYz1zSxsRhhABIA ### Repro steps Currently, the compiler memoizes the arguments of React hooks and regular functions when the arguments are non-primitive values. However, the behavior is inconsistent, and memoization is skipped when certain conditions are met: 1. The arguments passed to a React hook or regular function are non-primitive values (e.g., an object). 2. The argument object refers to another local variable, which is also non-primitive. 3. Both the React hook and the regular function reference the same local variable when constructing their arguments. Here is a minimal example: ```js const useCustomHook = (value) => { const data = { value }; return { prop1: useSomething({ data }), prop2: doSomething({ data }) }; }; ``` In the example, memoization of the `{ data }` argument passed to both `useSomething` and `doSomething` is skipped. ### How often does this bug happen? Every time ### What version of React are you using? 19.1.0 ### What version of React Compiler are you using? 19.1.0-rc.1
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by szhsin and has received 5 comments.