coroutine + fiber + asyncIterator
react-cocoroutine + fiber + asyncIterator
协程 + 纤程的一种尝试,利用异步迭代器,生成一个自执行的 React 工作单位
App.jsx
``js
import React from 'react'
import co from 'react-co'
const f = (url) => fetch(url).then(res => res.json())
async function* App(props) {
yield
const data = await f(props.url)
yield
export default co(App)
`
index.jsx
`js``
ReactDOM.render(
document.getElementById('root')
);