TanStack Query

setQueryData

Synchronously changes cached data; update immutable values and reconcile with the authority.

Formal Syntax & Structure

react syntaxreact
client.setQueryData(queryKey, updater)

Working Example

Example Snippetreact
client.setQueryData(["stock"],old=>old?{...old,available:2}:undefined);
React Reference