0.1.1 • Published 2 years ago
async-boundary v0.1.1
<AsyncBoundary>
A React async-boundary that couples an error-boundary as well as a suspense container
⚙️ Install
yarn add async-boundary
🚀 Usage
import { AsyncBoundary } from 'async-boundary';
const SuspensfulContainer = () => {
return (
<AsyncBoundary>
<SlowSuspensfulComponent />
</AsyncBoundary>
);
};
const SlowSuspensfulComponent = () => {
const data = resource.data.read();
return <h1>{data.thing}</h1>;
};
Please read more about suspense at Concurrent React (Suspense for Data Fetching)
🔎 API
AsyncBoundary: FunctionComponent
Props
fallback
: TheReactChild
to render whilst SuspendingerrorFallback
: TheReactChild
to render when an error occurred.- Has a
retryFn
callback passed to it, calling it will remount the<AsyncBoundary>
children.
- Has a
onError
: ThecomponentDidCatch
callback.
License
MIT © Marais Rossouw