empty data on refetch error
I have a simple useQuery that on success shows the correct data, but on error is returning empty.
If the example api returns a 500 the data is now an object with error in it. However I would like to keep the previous data (was a feature in v4 I believe).
This query is inside a custom hook and just returns
Since the hook returns data.timeEntires it then defaults to [] since timeEntires doesn't exist on the error data object.
@tanstack/react-query - ^5.18.1
2 Replies
vicious-gold•2y ago
Migrating to TanStack Query v5 | TanStack Query Docs
Breaking Changes
v5 is a major version, so there are some breaking changes to be aware of:
other-emerald•2y ago
I think the problem is that fetch does not raise an error on 500
Either implement it or use axios, ky, etc