It can not possibly be an official replacement to useEffect, setting state directly in render is prone to causing infinite loops. If React docs officially recommend setting state there, rather than cautiously mentioning that it may work in very certain situations, then they are just wrong. Do you have a link to docs where they recommend it?

Even this small example in the article causes an infinite loop, I'll add a link to the live example: https://codesandbox.io/s/vibrant-wilbur-02c4fc?file=/src/App.tsx

--

--

Frontend architect, coder. Love solving problems, fixing things and writing in-depth tech articles: https://www.developerway.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nadia Makarevich

Frontend architect, coder. Love solving problems, fixing things and writing in-depth tech articles: https://www.developerway.com