I get that the cleanup function runs just before the re-rendering. But what if it’s with an empty dependency? Is the cleanup function never called?
the useEffect hook will fire every time your component re-renders if you leave the dependency empty. Therefore your cleanup function will be called every time the component re-renders… at least from my knowledge.