How to fix Cannot update state on unmounted component. This is a no-op, but it indicates a memory leak in React | DevErrors