--

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

--

--