async-boundary
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

<AsyncBoundary>

CI

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: The ReactChild to render whilst Suspending
  • errorFallback: The ReactChild to render when an error occurred.
    • Has a retryFn callback passed to it, calling it will remount the <AsyncBoundary> children.
  • onError: The componentDidCatch callback.

License

MIT © Marais Rossouw

Package Sidebar

Install

npm i async-boundary

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

8.1 kB

Total Files

6

Last publish

Collaborators

  • marais