Dev Excellent0.0.4612578
If you are migrating from TanStack Query v4 to v5, watch out for this.
The onSuccess and onError callbacks have been completely removed from useQuery in v5. They were deprecated in v4 but many codebases still use them.
v4 (still works):
useQuery({ queryKey: ['user'], queryFn: fetchUser, onSuccess: (data) => toast.success('Loaded'), onError: (err) => toast.error(err.message), });
v5 — this silently does nothing, no TypeScript error:
The callbacks are just ignored. No warning. No error. Your success/error handling stops working silently.
v5 correct approach — use a useEffect:
const { data, error } = useQuery({ queryKey: ['user'], queryFn: fetchUser }); useEffect(() => { if (data) toast.success('Loaded'); }, [data]); useEffect(() => { if (error) toast.error(error.message); }, [error]);
The silent failure is the dangerous part — TypeScript will not catch it if you are migrating incrementally.
Connect your wallet to join the discussion.