Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools] Console logging and StrictMode double rendering #21889

Closed
4 tasks
bvaughn opened this issue Jul 15, 2021 · 2 comments · Fixed by #22030
Closed
4 tasks

[DevTools] Console logging and StrictMode double rendering #21889

bvaughn opened this issue Jul 15, 2021 · 2 comments · Fixed by #22030

Comments

@bvaughn
Copy link
Contributor

bvaughn commented Jul 15, 2021

React currently suppress all console logs while double rendering (or double invoking render phase lifecycles) to reduce console noise, e.g.:

if (
debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.mode & StrictLegacyMode
) {
disableLogs();
try {
nextChildren = renderWithHooks(
current,
workInProgress,
render,
nextProps,
ref,
renderLanes,
);
} finally {
reenableLogs();
}
}
setIsRendering(false);

Unfortunately this often causes confusion and leads to complaints (see the discussion on #21783). We could leverage DevTools to improve the default experience and give developers control over this behavior.

  • Disable console suppression by default in React.
  • Add an API for DevTools and React to communicate about when double rendering (or lifecycles) start and stop.
  • DevTools should gray out (but not hide) logs during second render pass by default.
  • DevTools should expose a new Debugging preference that allows users to suppress second logs entirely (mimicking the current default behavior).
@md-ziauddin
Copy link

I would like to work on this. If nobody is working on this. I can start working on exposing new debugging preferences as mentioned above. Could you please clarify the second point about adding an API for DevTools and React to communicate.

@bvaughn

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 3, 2021

Thanks for the offer, @ziauddin-copods, but Luna Ruan is working on this task. (It's assigned to her.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants