Potential memory leak in `useStore`?
objectliteral opened this issue · comments
Peter Steinberg commented
Currently, when a component has store access via useStore
or useSelector
and gets unmounted, React tells me this:
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Since useStore
doesn't set up subscriptions using useEffect
, I didn't expect any clean-up to be necessary, but apparently it is...
Components should be properly unsubscribed from receiving any updates when being unmounted as to not cause any memory leaks.