TanStackT
TanStack3y ago
24 replies
dead-brown

useQuery data is undefined even with initialData/placeholderData

Hey, i have a custom hook that returns a
useQuery
that fetches the options for a select input. I have tried with both
initialData
and
placeholderData
set as an empty array (which typewise is not incorrect, since I can have a select without options until they are added), but the data returned is set always set as
<T | undefined>
with
T
being the type of the options... Does it still require me to validate if
isSuccess
is true in order to set the type to
T
even though I have set the "default data"?

- @tanstack/react-query v4.24.4
- typescript v4.9.5
Was this page helpful?