T
TanStack•3y ago
rising-crimson

How to keep placeholder data if the initial fetch fails

If the initial fetch fails, is there a way to keep the placeholderData (note, i cant use initialData as it messes up with my stale time option) instead of data becoming undefined. I want placeholderData to be empty array, but as soon as the fetch fails, it becomes undefined which breaks my UI. No matter how i structure my query function, the data always becomes undefined and I have to use conditional chaining.
2 Replies
fascinating-indigo
fascinating-indigo•3y ago
const { data = [] } = useQuery(...
rising-crimson
rising-crimsonOP•3y ago
Thanks @TkDodo 🔮 ...

Did you find this page helpful?