News for hackers. Stuff that matters.
Re:PSA: React 18 calls code twice in strict dev mode to dete... by jitl on Sunday April 10, 2022 @12:00PM (#30978326)
React also already ran components twice when devtools is open, even without strict mode. This happens in my React 16 codebase with silenced console.log and no StrictMode in sight.
Re:PSA: React 18 calls code twice in strict dev mode to dete... by joshribakoff on Sunday April 10, 2022 @04:07PM (#30981166)
I think you mean it logged log messages twice?

I don’t believe having devtools opens changes the runtime semantics of the app.that would defeat the point of the devtools.

I do know it annoyingly logs things twice

Re:PSA: React 18 calls code twice in strict dev mode to dete... by jitl on Sunday April 10, 2022 @08:29PM (#30983221)
It doesn't log things twice, because DevTools replaces `console.log` and similar with no-op versions when they re-play the render. But it does call your component more times than you expect to power the DevTools hook inspector and other features.

Here's the code that turns off `console.log`: https://github.com/facebook/react/blob/b8cfda15e1232554487c7...

Re:PSA: React 18 calls code twice in strict dev mode to dete... by joshribakoff on Sunday April 10, 2022 @10:51PM (#30984044)
I haven’t seen anything about devtools altering runtime semantics but I may be wrong, that is something I think I disagree with because of the possibility to have bugs that go away when trying to debug