Update to React Strict Mode Double Rendering #96
lunaruan
announced in
Announcement
Replies: 2 comments
-
Awesome and very welcome change, thank you ❤️ |
Beta Was this translation helpful? Give feedback.
0 replies
-
I am trying to use this feature but it's not working. Still getting the double logs.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
We are no longer silencing console methods during the double render in Strict Mode.
Background
In Strict Mode, React double invokes render methods in order to flush out potential side effects. During the second render, React used to automatically silence console methods (ex.
console.log()
andconsole.warn()
) to reduce the noise of multiple repeat logs. However, this ended up causing a lot of confusion for developers during debugging, so we are changing this behavior.Double Render Behavior Changes
Going forward, React will no longer suppress logs during the second render by default. If you have React DevTools >
4.18.0
installed, logs during the second render will now show up in the console with muted colors.You can override this behavior in React DevTools >
4.18.0
by editing the “Hide logs during second render in Strict Mode” setting to hide the double logs (like before).Known Problems
Because DevTools overrides the native console to dim or suppress StrictMode double logging, it changes the location shown by the browser’s console. Previously, with component stacks, we were already overriding the console for
console.warn
andconsole.error
. However, with this change, we are now also overridingconsole.log
. We have a request for better browser console overrides, but in the meantime, we are looking into a solution to only patchconsole.log
during a double render to avoid this issue.Beta Was this translation helpful? Give feedback.
All reactions