useEffectAfterMount does not in React 18's strict mode in development environment, because react first mounts component, which sets isMounted.current to true, then unmounts component and mounts again. The problem is that isMounted.current is true on second mount.
Solution - reset isMounted.current on unmount.
useEffectAfterMountdoes not in React 18's strict mode in development environment, because react first mounts component, which setsisMounted.currenttotrue, then unmounts component and mounts again. The problem is thatisMounted.currentis true on second mount.Solution - reset
isMounted.currenton unmount.