1.0.5 • Published 3 years ago
@tdotcode/react-lazy-retry v1.0.5
react-lazy-retry
This is a lazyRetry that wraps Reacts lazy loading function. Implementation below
Geting started
// npm
npm intall @tdotcode/react-lazy-retry
// yarn
yarn add @tdotcode/react-lazy-retry
Usage
- This will retry 5 times spaced out for 1 second between retries
import React from "react";
import lazyRetry from "@tdotcode/react-lazy-retry";
const Greeting = lazyRetry(() => import("./components/Greeting"));
function App() {
return (
<Suspense fallback={null}>
<Greeting />
</Suspense>
);
}
- You can also control number of retries and duration between retries. In this example we are retrying 10 times spaced out for 100ms
import React from "react";
import lazyRetry from "@tdotcode/react-lazy-retry";
const Greeting = lazyRetry(() => import("./components/Greeting"), 10, 100);
function App() {
return (
<Suspense fallback={null}>
<Greeting />
</Suspense>
);
}