TanStackT
TanStack2y ago
4 replies
sad-indigo

How to implement a callback/action when the query is successful?

Hi there previously I did something like this

// On success, omgevingscheck data is saved in cache and in ctx.
export function useOmgevingscheck({ wkt, verzoekAard }: IBodyProps) {
  const setOmgevingscheckResultInCtx = useSetOmgevingscheckResult();

  return useQuery({
    queryKey: ['useOmgevingscheck', { wkt, verzoekAard }],
    queryFn: () => getOmgevingscheck({ wkt, verzoekAard }),
    enabled: !!wkt,
    // [FIXME]: Replace onSuccess want het is deprecated
    onSuccess: (data: IOmgevingscheckResult) => {
      setOmgevingscheckResultInCtx(data);
    },
  });
}


but onSuccess and onError have been deprecated, what do I need to use in the v5 api to arrive at the same functionality?

Thanks
Was this page helpful?