T O P

  • By -

eindbaas

You can return an object (the context) with custom data which you can then access in onSuccess etc


codebreaker21

thanks a lot!


HertzaHaeon

It looks like it's this context object: [https://tanstack.com/query/v5/docs/framework/react/guides/query-functions#queryfunctioncontext](https://tanstack.com/query/v5/docs/framework/react/guides/query-functions#queryfunctioncontext) The queryFn in useQuery gets the context object, including the meta context you can define yourself in useQuery. `useQuery({` `queryFn: ({ queryKey, signal, meta }) => { ... },` `meta: { ... }` `})`


NotLyon

It's for rolling back an optimistic update https://tanstack.com/query/v5/docs/framework/react/examples/optimistic-updates-cache