Overview
A React component that renders the results of an ES2015 generator.
The suspense is killing me, so I decided to explore this before React implements it themselves!
Getting started
Install
npm i react-suspense-saga
or
yarn add react-suspense-saga
Quick Example
import runner from 'react-suspense-saga'import call render from 'react-suspense-saga/effects' import Api from './Api' { try const user = catche } greeter
Demos
API Documentation
Call
: Effect
This will instruct the runner to return the results of the promise back to the
generator when it resolve
s or reject
s.
eg.
const AsyncGreeting =
delay
: Effect
This will instruct the runner to use setTimeout
.
eg.
const MyComponent =
render
This will render a node or a react component.
eg.
const Loading = <p>Loading...</p> const MyComponent =
takeProps
: Effect
This is a blocking effect, that will not advance the generator until the props have changed.
You can use this with redux
, or any component that will change the props like
this:
const AsyncGreeting =