react.dev
react.dev copied to clipboard
The double rendering of lifecycle methods in Strict Mode needs to be presented more loudly
I have just lost a day's work wondering why my GSAP animations weren't working only to realize the double call in strict mode. While I understand the reasons for strict mode, I still think having a Caveats section or something to warn developers would be highly beneficial.
I did stumble on this GSAP thread and it seems like both sides are just saying "It's not really my problem" while we the developers kind of suffer.
Now, I do know of the existence of the changelog but new developers wouldn't be aware of this issue right away and I just want to save their time. So, maybe having a Gotchas section where you can just write some notes regarding how strict mode calling twice may affects 3rd party libraries like GSAP's from() tweens could help developers tackle this issue early? Just my two cents.
There are multiple references of rendering twice in development mode in docs. like https://beta.reactjs.org/apis/useref#returns the last point here and https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects