What are you talking about? The setInterval example is completely idiomatic React hooks. It is literally given in the React docs:
https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-...
https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-...
That was really my point, don't do that.