TanStackT
TanStack3y ago
2 replies
specific-silver

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.
Was this page helpful?