https://github.com/marvinhagemeister/preact-loadable
Tiny preact component for async tasks
https://github.com/marvinhagemeister/preact-loadable
async loadable preact
Last synced: 3 months ago
JSON representation
Tiny preact component for async tasks
- Host: GitHub
- URL: https://github.com/marvinhagemeister/preact-loadable
- Owner: marvinhagemeister
- License: mit
- Created: 2017-10-31T07:09:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-20T10:00:55.000Z (over 8 years ago)
- Last Synced: 2025-04-15T18:40:31.194Z (about 1 year ago)
- Topics: async, loadable, preact
- Language: TypeScript
- Size: 36.1 KB
- Stars: 24
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list - preact-loadable
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).