Loading…
Loading…
New UserProfile component in the project. A colleague adds it — fetch data when userId changes, show loading, then the profile. When switching quickly, UX testers notice "flashes" of old data. Walk the diff and explain the cause.
Any request with a changing parameter (userId, filter, page) is vulnerable to a race. Classic scenario: 1. Effect starts request A. 2. Parameter changes → effect starts request B. 3. Responses arrive in unpredictable order. 4. If A arrives second — it overwrites B. Fix — a cleanup function in useEffect that marks the previous request as cancelled. Scan the code and find where this wasn't done.