async-reactor
Render async Stateless Functional Components
Installation
npm install --save async-reactor
Usage
: Component
name | type | description |
---|---|---|
component | Function (async) | The async component you want to render |
loader (optionnal) | Component | Will be shown until the first component renders |
error (optionnal) | Component | Will be shown when an error occurred |
The returned value is a regular Component
.
Examples
This examples are exporting a regular React component. You can integrate it into an existing application or render it on the page.
See more examples here
Using code splitting
; { return <b>Loading ...</b> ;} { const moment = await import'moment'; const time = ; return <div> time </div> ;} Time Loader;
Using fetch
;; { return <h2>Loading ...</h2> ;} { const data = await ; const posts = await data; return <ul> posts </ul> ;} AsyncPosts Loader;