The reason is that the callback passed to this.cleanup() does not get called on already unmounted components, which can happen in this component when it unmounts before the setTimeout() promise settles.
Preliminary thoughts. The best way to fix this is to call the cleanup function immediately.
While working on the homepage, the following function started causing "Component is unmounted" errors. Can you guess why?
The reason is that the callback passed to
this.cleanup()
does not get called on already unmounted components, which can happen in this component when it unmounts before thesetTimeout()
promise settles.Preliminary thoughts. The best way to fix this is to call the cleanup function immediately.