react icon indicating copy to clipboard operation
react copied to clipboard

compiler: fix accidental propagation of function effects from StartMemoize/FinishMemoize

Open josephsavona opened this issue 1 year ago • 2 comments

Stack from ghstack (oldest at bottom):

  • -> #29154
  • #29151

By default, React Compiler will skip compilation if it cannot preserve existing memoization. Ie, if the code has an existing useMemo() or useCallback() and the compiler cannot determine that it is safe to keep that memoization — or do even better — then we'll leave the code alone. The actual compilation doesn't use any hints from existing memo calls, this is purely to check and avoid regressing any specific memoization that developers may have already applied.

However, we were accidentally reporting some false-positive validation errors due to the StartMemoize and FinishMemoize instructions that we emit to track where the memoization was in the source code. This is now fixed.

Fixes #29131 Fixes #29132

josephsavona avatar May 17 '24 22:05 josephsavona

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2024 10:31pm

vercel[bot] avatar May 17 '24 22:05 vercel[bot]

Comparing: 1d6eebfb7ff44b24627ef404112bb151f683efe7...8210d3bf7572f0a2eef3b15c8ad76fd18d4642d9

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB +0.05% 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 495.01 kB 495.01 kB = 88.68 kB 88.68 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 499.81 kB 499.81 kB = 89.36 kB 89.36 kB
facebook-www/ReactDOM-prod.classic.js = 592.16 kB 592.16 kB = 104.15 kB 104.15 kB
facebook-www/ReactDOM-prod.modern.js = 568.39 kB 568.39 kB = 100.55 kB 100.55 kB
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against 8210d3bf7572f0a2eef3b15c8ad76fd18d4642d9

react-sizebot avatar May 17 '24 22:05 react-sizebot