PeformP
tRPC2y ago
4 replies
Peform

useQuery `onSuccess` callback depreciated

Hello. I've just found out that the
onSuccess
callback in useQuery has been depreciated. What should I be using instead?
This callback will fire any time the query successfully fetches new data.

@deprecated — This callback will be removed in the next major version.

  const {
    data: fetchedUserData,
    refetch: refetchUserData,
    isFetching: fetchingUserData,
  } = api.userLookup.find.useQuery(
    {
      userId: form.getValues("userId"),
    },
    {
      enabled: !!form.getValues("userId"),
      onSuccess: (data) => { // depreciated
        setUserData(data);
      }
    },
  );
Was this page helpful?