Proje: OkulUp · Hub: OkulUp — Architecture
React Query Konfigürasyonu
QueryClient Varsayılan Ayarları
defaultOptions: {
queries: {
staleTime: 5 dakika, // 5 * 60 * 1000
refetchOnWindowFocus: false, // React Native'de window focus yok
retry: (failureCount, error) => {
// Bunlarda retry yok:
if (error instanceof ForbiddenError) return false; // 403
if (error instanceof NotFoundError) return false; // 404
if (error instanceof UnauthorizedError) return false; // 401
return failureCount < 2; // Diğerlerinde max 2 retry
},
},
mutations: {
retry: 0, // Mutation'larda hiç retry yok
},
}ErrorBoundary
ErrorBoundary React class component — Sentry.captureException ile entegre.
Crash durumunda ErrorView gösterilir, retry butonu var.
queryClient Export
queryClient doğrudan import edilebilir — mutation sonrası manuel invalidation için:
import { queryClient } from '@/components/providers';
queryClient.invalidateQueries({ queryKey: [...] });Önemli Notlar
refetchOnWindowFocus: false— mobile’da sayfa focus geçişleri olmadığı için- 401/403/404’te retry yok — kullanıcı deneyimini bozmamak için
useRefreshOnFocushook manuel olarak focus’ta refetch sağlıyor
Related
- react-query-hooks-pattern — query key ve hook pattern’leri
- api-client-architecture — error sınıfları