react/compiler/packages/react-compiler-runtime
Mike Vitousek 522d22f299 [compiler] Recompute values every time
Summary: This PR expands the analysis from the previous in the stack in order to also capture when a value can incorrectly change within a single render, rather than just changing between two renders. In the case where dependencies have changed and so a new value is being computed, we now compute the value twice and compare the results. This would, for example, catch when we call Math.random() in render.

The generated code is a little convoluted, because we don't want to have to traverse the generated code and substitute variable names with new ones. Instead, we save the initial value to the cache as normal, then run the computation block again and compare the resulting values to the cached ones. Then, to make sure that the cached values are identical to the computed ones, we reassign the cached values into the output variables.

ghstack-source-id: d0f11a4cb2
Pull Request resolved: https://github.com/facebook/react/pull/29657
2024-05-31 14:06:02 -07:00
..
src [compiler] Recompute values every time 2024-05-31 14:06:02 -07:00
package.json [publish] Fix files field for packages, invalid version range 2024-05-14 11:02:29 -04:00
rollup.config.js Rename react-compiler-runtime 2024-05-02 17:14:26 -07:00
tsconfig.json Rename react-compiler-runtime 2024-05-02 17:14:26 -07:00