Debugging, performance, and security scenarios
Senior interviews increasingly ask what do you do next? rather than asking for API definitions.
Scenario-answer methodโ
For an active incident, mitigation or rollback may come before complete diagnosis.
Slow input with thousands of resultsโ
Do not begin with โadd useMemo and useCallback.โ
Scheduling can improve responsiveness without reducing the total CPU cost.
Broad Context rerendersโ
A provider mixing user, theme, notifications, live prices, permissions, and commands may create broad coupling.
Effect repeatedly reconnectsโ
useEffect(() => {
const socket = connect({ roomId, options });
return () => socket.close();
}, [roomId, options]);
If options is recreated every render, the dependency changes by identity. Prefer deriving stable primitive dependencies or creating the object inside the Effect when that matches semantics. Do not delete dependencies to silence the linter.
Fetch raceโ
A Transition does not solve stale network responses.
State appears on the wrong rowโ
If editable rows use key={index}, sorting can move component state to a different logical record. Use stable domain identity such as key={record.id}.
Form submits twiceโ
Optimistic update conflicts with live server eventโ
Hydration mismatch only in productionโ
Investigate time/timezone, randomness, browser-only APIs, locale, server/client feature flags, session snapshots, invalid HTML, and third-party DOM mutation.
Suspense fallback replaces whole pageโ
Boundary placement may be too high, navigation may not use Transition semantics, nested reveal structure may be missing, or identity may intentionally reset. Design reveal groups from UX.
Lazy chunk fails after deploymentโ
Memory grows over timeโ
Check missing subscription/timer/listener cleanup, third-party teardown, unbounded caches, retained closures, and detached DOM. Reproduce repeated mount/unmount, inspect heap retention after GC, and verify cleanup invariants.
Infinite Effect loopโ
useEffect(() => {
setItems(transform(items));
}, [items]);
Ask first whether the value should be derived during render. Do not โfixโ the loop by hiding a real dependency.
memo did not helpโ
Fast locally, slow in productionโ
Compare realistic data, network, device CPU, production build, third-party scripts, hydration/server latency, cache state, feature flags, and observability instrumentation.
Security scenario methodโ
What a strong scenario answer sounds likeโ
The goal is not to name the most React APIs. It is to isolate the actual failure and choose the smallest change that addresses its real cause.