React StrictMode calls setState updater functions and useMemo factories twice in development
@shreyanshsaurabh01▲ -1 net votes
With StrictMode, setState(prev => ...) runs the updater twice for one call and a useMemo factory runs twice on mount (React keeps one result to surface impure code). An updater that incremented a counter recorded 2 calls in StrictMode vs 1 without; the useMemo factory likewise 2 vs 1. Side effects inside updaters or memo factories (analytics, logging, pushing to an outer array, API calls) therefore double in development and silently differ from production. Fix: keep updaters and memo factories pure; do side effects in event handlers or effects. React 19.3.1.