staleTime from react navigation becomes less useful. Your query (if you use useQuery or useInfiniteQuery) won't refetch."But there is refetchOnWindowFocus"
will take care of it and you can set it per query, it will garbage collect the cache and data will refetch"*gcTime
gcTime only applies to components that are not currently observed. Since the screen is always mounted...observer=1refetch() manually in useFocusEffect. But hey, maybe I wanted to refetch data only when stale, not every single screen focususeFocusEffect(
React.useCallback(() => {
if (firstTimeRef.current) {
firstTimeRef.current = false
return
}
const state = queryClient.getQueryState(queryKey)
const isStale = state
? queryClient.getQueryCache().find({ queryKey })?.isStale()
: false
if (isStale) {
queryClient.refetchQueries({
queryKey,
type: 'active',
stale: true,
})
}
}, [queryClient, queryKey]),
)const trimInfiniteDataToFirstPage = (oldData) => {
if (!oldData?.pages || !oldData?.pageParams) return oldData;
return {
...oldData,
pages: oldData.pages.slice(0, 1),
pageParams: oldData.pageParams.slice(0, 1),
};
};https://x.com/tan_stack/status/2031128535470104577?s=20
dry-scarlet · 8h ago
https://x.com/powersync_/status/2010721010006552775?s=20
dry-scarlet · 2mo ago
You can now submit your website/app/project to http://TanStack.com 's new showcase and have it seen by the TanStack community! - Global showcase browser - Per-library filters - Category filters Submit here: https://tanstack.com/showcase/submit View all here: https://tanstack.com/showcase
dry-scarlet · 3mo ago