-
Hey, I'm stumped trying to figure this out. I've got a fairly straightforward query, and I'm using it in a component that gets recreated in a virtual scroller to render a select box. Whenever I scroll, the query fires again for all the instances of the new component, even though they all have the exact same key. Why might this be happening? Here's the composable that creates my query. The account passed in is a ref that does not change. export const useListTerminalsQuery = account => {
const store = useStore();
const {
data: terminals,
isLoading: isLoadingTerminals,
...query
} = useQuery({
key: () => TERMINAL_QUERY_KEYS.byRoleForAccount(store.getters.account.role, account.value),
query: () => api.accounts(account.value).terminals.index({ depots: false }),
placeholderData: previousData => previousData ?? [],
staleTime: 4 * 60 * 60 * 1000, // 4 hours
});
return {
...query,
isLoadingTerminals,
terminals,
};
}; My understanding is that this shouldn't require |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
If it’s fully shared, defineQuery will ensure one single version but yours have an argument so it’s better with defineQueryOptions the refetch might be due to dev mode #320 |
Beta Was this translation helpful? Give feedback.
-
Aha, I really wasn't familiar with |
Beta Was this translation helpful? Give feedback.
-
Looks like I spoke too soon. Once I finished converting all my invocations of |
Beta Was this translation helpful? Give feedback.
Sounds like #320