- Notifications
You must be signed in to change notification settings - Fork27
Render async Stateless Functional Components in React
License
NotificationsYou must be signed in to change notification settings
xtuc/async-reactor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Render async Stateless Functional Components
npm install --save async-reactor
asyncReactor(component:Function,loader?:Component,error?:Component):Component
| name | type | description |
|---|---|---|
| component | Function (async) | Theasync 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 regularComponent.
This examples are exporting a regular React component.You can integrate it into an existing application or render it on the page.
See more exampleshere
importReactfrom'react'import{asyncReactor}from'async-reactor';functionLoader(){return(<b>Loading ...</b>);}asyncfunctionTime(){constmoment=awaitimport('moment');consttime=moment();return(<div>{time.format('MM-DD-YYYY')}</div>);}exportdefaultasyncReactor(Time,Loader);
importReactfrom'react';import{asyncReactor}from'async-reactor';functionLoader(){return(<h2>Loading ...</h2>);}asyncfunctionAsyncPosts(){constdata=awaitfetch('https://jsonplaceholder.typicode.com/posts');constposts=awaitdata.json();return(<ul>{posts.map((x)=><likey={x.id}>{x.title}</li>)}</ul>);}exportdefaultasyncReactor(AsyncPosts,Loader);
About
Render async Stateless Functional Components in React
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.