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.

•3m read time•From h.daily-dev-tips.com
Post cover image
Table of contents
Clear your timeouts!React useTimeout hook
9 Comments

Sort: