Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Usually not: Strict Mode in development mounts, unmounts and mounts components again to reveal effects that lack proper cleanup. It does not happen in production.
React's Strict Mode deliberately runs extra renders and an extra effect setup and cleanup cycle in development. If your effect works correctly, the double run is harmless: the first subscription is cleaned up before the second starts. If it causes a visible problem, such as two requests that both update state or a duplicated listener, the effect is missing cleanup or is doing work that belongs in an event handler. The fix is to add cleanup, not to disable Strict Mode or add a ref flag to skip the second run.