Open
Description
Describe the bug
I've run into issues several times that are caused by calling cleanup functions during the rendering phase. First time in the UI library (a similar case is described here #4222). The second time with a library that prohibits data modification at the rendering stage.
It would be nice for React compatibility and to prevent problems like this to call cleanup functions on hooks after rather than during rendering.