Skip to content

Commit db008ec

Browse files
fix return statement usage in async generator
1 parent f057435 commit db008ec

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## react-coroutine v0.5.1
2+
3+
* Fix `return` statement usage in async generators
4+
15
## react-coroutine v0.5.0
26

37
* Use a better approach to check if component is mounted

modules/Coroutine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function create(asyncFn, getVariables = () => ({})) {
3030
this.iterator = asyncBody;
3131
const getNextBody = () => {
3232
asyncBody.next().then((body) => {
33-
if (body.done) {
33+
if (body.done && typeof body.value === 'undefined') {
3434
this.iterator = null;
3535
} else {
3636
this.setState(() => ({ body: body.value, variables }));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-coroutine",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "React Components as Coroutines",
55
"main": "lib/Coroutine.js",
66
"scripts": {

tests/Coroutine.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('Coroutine', async () => {
6262
async function* render() {
6363
yield <p>Loading...</p>;
6464
await Promise.resolve();
65-
yield <p>Done!</p>;
65+
return <p>Done!</p>;
6666
}
6767

6868
const TestComponent = Coroutine.create(render);

0 commit comments

Comments
 (0)