useListData with Tanstack Query #6179
Answered
by
reidbarber
writes-of-spring
asked this question in
Q&A
-
Hey! when using data returned from a tanstack query hook as initial data in the useListData hook is always returning an empty list in the returned properties. const { data = [], isLoading, isError } = useQuery(farmsQueryOptions);
const list = useListData({
initialItems: data,
getKey: (item) => item.id,
}); I know there's useAsyncList but was trying to use useListData combined with tanstack query for cache invalidation / synchronisation, and it can be worked around by fetching data and passing it into a useListData component, but was wondering if I'm missing anything simple! Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
reidbarber
Apr 10, 2024
Replies: 1 comment 3 replies
-
By using |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To set the default data, I think you want to pass initialData into useQuery.
And yes, initialItems is meant to be for initial render, so I'm not sure using these two hooks together will work if the data isn't ready.