1.0.0 • Published 6 years ago

preact-loadable v1.0.0

Weekly downloads
9
License
MIT
Repository
-
Last release
6 years ago

Preact Loadable

A simple component to display the promise state of a promise returning function or any other async task.

Installation

# npm
npm install --save preact preact-loadable

# yarn
yarn add preact preact-loadable

Usage

import { h } from "preact";
import Loadable from "preact-loadable";

function MyComponent() {
  return <div>
    <Loadable
      // Can be sync or async
      fn={() => import("../MyOtherComponent").then(m => m.default())}
      error={err => "Oops, an error occurred: " + err.message}
      loading={() => "Loading..."}
      success={result => doSomething(result)}
    />
  </div>;
}

License

MIT, see License file.

1.0.0

6 years ago

0.0.1

7 years ago