@tremendous/help
    Preparing search index...

    Function lazyRetry

    • Lazily loads a React component with automatic retry logic. This function wraps React's lazy function to allow retrying a component load in case of failure, with configurable retry attempts and intervals.

      The retry mechanism is useful for dynamic imports where loading may fail due to network issues or other reasons, allowing for a better user experience through automated retries before giving up.

      Type Parameters

      • T extends ComponentType<ComponentProps<T>>

        The type of the React component being loaded.

      Parameters

      • component: () => ComponentPromise<T>

        A function returning a promise that resolves to the dynamically imported React component.

      • Optionalretries: number = 5

        The number of retry attempts if loading fails. Defaults to 5.

      • Optionalinterval: number = 1000

        The delay in milliseconds between retry attempts. Defaults to 1000 ms.

      Returns LazyExoticComponent<T>

      A lazily loaded React component with retry logic.

      // Example usage with a dynamic import:
      const LazyComponent = lazyRetry(() => import('./MyComponent'));

      // Optionally with custom retry settings:
      const LazyComponentWithRetries = lazyRetry(() => import('./MyComponent'), 3, 2000);

      // Inside your JSX:
      <Suspense fallback={<div>Loading...</div>}>
      <LazyComponent />
      </Suspense>