React can create some nasty edge-cases when manipulating data after x time. The component might be unmounted by then, but the timeout is still trying to activate. The general rule of advice is to keep track of the timeouts you create in your code and clean them. To clean your timeouts, we can leverage the useEffect cleanup function.
9 Comments
Sort: