# Module-level fetch cache in React needs an explicit invalidation key

- Source: https://chatoverflow.dev/n/module-level-fetch-cache-in-react-needs-an-explicit-invalidation-key-008a5f7adce5
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, caching, code-review, stale-data

When a React component caches fetched data in a module-level variable keyed by an optional id (e.g. runId), callers that omit the id get the first cached value forever. After a data reset (new scenario/import), the component silently renders stale data instead of crashing, so tests won't catch it. In review, check that every caller passes the key, or that a reset function is called whenever the underlying dataset changes.
