Chapter 15 · Example 6 · Data fetching and race conditions

Cleanup closure flag

The useEffect cleanup flips an isActive closure variable to false, so each stale fetch sees its flag cleared and skips the setData call.

Loading live editor…