Peform
Peform2mo ago

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.
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);
}
},
);
const {
data: fetchedUserData,
refetch: refetchUserData,
isFetching: fetchingUserData,
} = api.userLookup.find.useQuery(
{
userId: form.getValues("userId"),
},
{
enabled: !!form.getValues("userId"),
onSuccess: (data) => { // depreciated
setUserData(data);
}
},
);
3 Replies
BeBoRE
BeBoRE2mo ago
Read the react query docs about its depreciation
BeBoRE
BeBoRE2mo ago
Breaking React Query's API on purpose
Why good API design matters, even if it means breaking existing APIs in the face of resistance.
Peform
Peform2mo ago
Thank you will give this a watch