react icon indicating copy to clipboard operation
react copied to clipboard

Devtools: Ensure component control flow is consistent with commit when using `useDeferredValue

Open eps1lon opened this issue 11 months ago • 1 comments

Stacked on https://github.com/facebook/react/pull/28467

Summary

We used to always return the value that was passed into useDeferredValue in react-debug-tools. This could cause your component to behave differently when it was inspected in Devtools. This is less of an issue when hooks cannot be called conditionally but use can.

That's why I stacked it on https://github.com/facebook/react/pull/28467 where you can also observe the "Context reads do not line up" crash when you instead write

-const contextDisplay = isPending ? React.use(Context) : '<none>';
+const contextDisplay = isPending ? '<none>' : React.use(Context);

Test plan

  • Adedd test to packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js (review by commit to see change of behavior)

eps1lon avatar Mar 06 '24 20:03 eps1lon

Comparing: 9ffe9102ffd08ca7a56c60aa6952208890d213ce...f94d6f746c5b62554fcf8bd5c679a85de8ee5128

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.min.js = 176.83 kB 176.83 kB = 54.91 kB 54.91 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 173.55 kB 173.55 kB = 54.11 kB 54.11 kB
facebook-www/ReactDOM-prod.classic.js = 594.04 kB 594.04 kB = 104.37 kB 104.37 kB
facebook-www/ReactDOM-prod.modern.js = 577.30 kB 577.30 kB = 101.42 kB 101.42 kB
test_utils/ReactAllWarnings.js Deleted 66.87 kB 0.00 kB Deleted 16.36 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 66.87 kB 0.00 kB Deleted 16.36 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against f94d6f746c5b62554fcf8bd5c679a85de8ee5128

react-sizebot avatar Mar 06 '24 20:03 react-sizebot