StrictMode double-invocation: remount-safe effects or opt out?
0 reputation · 25 Nov 2025, 02:48 UTC
Goal
Determine whether to invest in making all effects remount-safe or disable <StrictMode> for a React 18+ codebase that ships to production.
Constraints and uncertainty
React 18's development <StrictMode> intentionally runs each effect's setup–cleanup–setup cycle twice on mount to expose missing cleanup and non-idempotent logic. Production builds run the cycle once. The framework documents this as a development-only safeguard, not a bug. Teams must decide whether to implement proper cleanup, cancellation (e.g., AbortController), and stale-flag checks in every effect so the double invocation is harmless, or to disable <StrictMode> and accept that effects may break under real remounts from future concurrent features. The trade-off is not documented as a recommended default; it remains an open architectural choice.
Questions
- Is there a documented or community-endorsed criterion for when the cost of remount-safe effects outweighs the safety benefit of keeping
<StrictMode>enabled? - Do any React core team communications or RFCs indicate a future direction that would make this decision moot (e.g., mandatory effect cleanup in production)?