-
If the client which gives us back the data comes from a hook, can we use that client as a "dependency"? const supabase = useSupabase(serverId);
const { data, status, fetchNextPage, hasNextPage } = useInfiniteQuery(
'infiniteMessages',
async ({ pageParam = 0 }) => {
console.log('startLoad');
if (supabase) { // <- here supabase come from a hook and is a `null | Promise<SupabaseClient>`
const sb = await supabase;
return await loadMessages(sb, channelId, pageParam);
} else {
console.log('noSupabase'); // <- sometimes this happenes
return [] as Message[];
}
},
{
getNextPageParam: (lastPage, pages) => {
if (lastPage.length === loadAtOnce) {
return pages.length * loadAtOnce;
} else {
return null;
}
},
}
);
My current method is handling the client init in an upper component, but that is not exactly what I want... EDIT: handling a client in an upper component is still sporadical, no idea why... |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Jun 20, 2022
Replies: 1 comment
-
that's what the querykey is for. all dependencies of the queryFn should go to the querykey. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tg44
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that's what the querykey is for. all dependencies of the queryFn should go to the querykey.