type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);Defined in: packages/query-core/src/utils.ts:103
Either a plain value of type TOutput, or a function that receives TInput and returns TOutput. Used for example by setQueryData-style updaters, which accept either the new data directly or a function that computes it from the previous data. See functionalUpdate.
TInput
TOutput
queryClient.setQueryData(['posts'], newPosts)
// Or, using an updater function that receives the current data:
queryClient.setQueryData(['posts'], (oldPosts) =>
oldPosts ? [...oldPosts, newPost] : oldPosts,
)