react
react copied to clipboard
Dim `console` calls on additional Effect invocations due to `StrictMode`
Stack:
- https://github.com/facebook/react/pull/29006
- https://github.com/facebook/react/pull/29008
- https://github.com/facebook/react/pull/29007 <-- You're here
Summary
Same as https://github.com/facebook/react/pull/22030 but for double invocations of Effects due to StrictMode:
Before/After
This means that console calls during the double invocations of Effects due to StrictMode can be disabled in React DevTools.
The option has been renamed from "Hide logs during second render in Strict Mode" to "Hide logs during additional invocations in Strict Mode". Not sure if "additional invocations" is clear enough. "additional function calls" is just slightly longer and may be clearer?
This also means that tests using Scheduler.log no longer have to assert on the additional invocations (just like Scheduler.log during double invocations of render-time functions due to StrictMode).
How did you test this change?
- additional tests like https://github.com/facebook/react/pull/22030 added but for Effects
- extension+build from this branch and console calls during Effects: https://codesandbox.io/p/sandbox/react-devtools-console-calls-during-second-effect-invocation-due-to-strict-mode-6yfd4g
Comparing: 81c5ff2e040ee56b85b8bd27a2f8065661f17fee...8eb27a1a32a8c3d175787550b105d07c4b05499f
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.89 kB | 495.89 kB | = | 88.82 kB | 88.83 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 | = | 500.69 kB | 500.69 kB | = | 89.51 kB | 89.51 kB |
| facebook-www/ReactDOM-prod.classic.js | = | 593.05 kB | 593.05 kB | = | 104.32 kB | 104.32 kB |
| facebook-www/ReactDOM-prod.modern.js | = | 569.27 kB | 569.27 kB | = | 100.72 kB | 100.72 kB |
| test_utils/ReactAllWarnings.js | Deleted | 64.35 kB | 0.00 kB | Deleted | 16.05 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.35 kB | 0.00 kB | Deleted | 16.05 kB | 0.00 kB |
Generated by :no_entry_sign: dangerJS against 8eb27a1a32a8c3d175787550b105d07c4b05499f
Not sure if "additional invocations" is clear enough. "additional function calls" is just slightly longer and may be clearer?
Can you make the Strict Mode text clickable in the new updated label? It should link to https://react.dev/reference/react/StrictMode, I believe this would help users understanding why they are having 2 invocations
Also, could you please update function names here to reflect these changes?
@eps1lon is attempting to deploy a commit to the Meta Open Source Team on Vercel.
A member of the Team first needs to authorize it.
Can you make the Strict Mode text clickable in the new updated label?
Also, could you please update function names here to reflect these changes?
Done: efdb1e8 (#29007)
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 22, 2024 9:33am |
This is a little different than render in that the render isn't a side-effect so it can be called 1 or 100 times and it's the same thing. Effects can't be said the same so hiding the logs might be misleading. Additionally, it just covers logs directly inside the effect where as it can spawn more work that happens outside the effect twice.