Skip to content

Commit cb2bdef

Browse files
Fix the usage of contextTypes for async functions
1 parent 8126339 commit cb2bdef

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
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 v1.0.1
2+
3+
* Fix `contextTypes` usage for async functions
4+
15
## react-coroutine v1.0.0
26

37
* Use Rollup to build smaller bundle

modules/CoroutineFactory.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ export default function create(asyncFn, getVariables = () => ({})) {
88
return `Coroutine(${componentName})`;
99
}
1010

11+
static get contextTypes() {
12+
return asyncFn.contextTypes;
13+
}
14+
1115
constructor(props, context) {
1216
super(props, context);
1317
const variables = getVariables(props, context);
1418
const body = variables.placeholder || this.state.body;
1519
this.state = { body, variables };
1620
this.asyncFunction = asyncFn;
1721
}
22+
23+
componentWillReceiveProps(nextProps, nextContext) {
24+
const variables = getVariables(nextProps, nextContext);
25+
this.setState(() => { variables }, () => super.componentWillReceiveProps(nextProps));
26+
}
1827
}
1928
}

0 commit comments

Comments
 (0)