RMQ001 — a query key that cannot be hashed
A key is turned into a string to find its cache entry, so what it holds has to survive that trip. Two kinds of value do not, and each fails in its own direction:
Dropped entirely — a function or a symbol. JSON.stringify omits them, so
["user", fn] and ["user", otherFn] hash identically: two queries share one entry and
each renders the other's data. Put the value you were about to close over in the key —
["user", id] — and keep the function in the fetcher.
Serialized unstably — a Date, a Map, a class instance. A Date becomes a timestamp that
differs on the next render, so the entry is never found again and every render starts a new
fetch; a Map or a class instance becomes whichever of its fields happen to be enumerable,
which is often nothing at all. Put a primitive in the key —
date.toISOString().slice(0, 10), or the id — and keep the object in the fetcher.
Both are checked when the key is hashed, and the message names the kind it found. Arrays and plain objects are walked, to a depth of ten.
Next
- All diagnostics — every code the framework can report.
- Checking your app — the faults proved from the source, before anything runs.