Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marvinhagemeister/preact-loadable

Tiny preact component for async tasks
https://github.com/marvinhagemeister/preact-loadable

async loadable preact

Last synced: about 2 months ago
JSON representation

Tiny preact component for async tasks

Awesome Lists containing this project

README

        

# Preact Loadable

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

## Installation

```bash
# npm
npm install --save preact preact-loadable

# yarn
yarn add preact preact-loadable
```

## Usage

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

function MyComponent() {
return


import("../MyOtherComponent").then(m => m.default())}
error={err => "Oops, an error occurred: " + err.message}
loading={() => "Loading..."}
success={result => doSomething(result)}
/>
;
}
```

## License

`MIT`, see [License file](LICENSE.md).