Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
OchiengPaul442 committed Jan 26, 2025
1 parent f0738d1 commit 9c76dd0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions website2/src/hooks/swrConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export const swrOptions = {
import type { SWRConfiguration } from 'swr';

export const swrOptions: SWRConfiguration = {
// Revalidate data on focus of the window (when the user returns to the tab)
revalidateOnFocus: true,
revalidateOnFocus: false,

// Revalidate data when the browser reconnects to the network
revalidateOnReconnect: true,
revalidateOnReconnect: false,

// Disable automatic refreshing at intervals
refreshInterval: 0,
Expand All @@ -13,6 +15,15 @@ export const swrOptions = {

// Retry fetching on error settings
shouldRetryOnError: true,
errorRetryCount: 3,
errorRetryCount: 2, // This will result in 3 total attempts (initial + 2 retries)
errorRetryInterval: 5000,

// Custom onErrorRetry function to stop retrying after 3 attempts
onErrorRetry: (error, key, config, revalidate, { retryCount }) => {
// Only retry up to 2 times (3 total attempts)
if (retryCount >= 2) return;

// Retry after 5 seconds
setTimeout(() => revalidate({ retryCount: retryCount + 1 }), 5000);
},
};

0 comments on commit 9c76dd0

Please sign in to comment.