@samitouri / QOS-React / commits / 975ad92e68

Don't bail to .child of coroutines

This should bail to stateNode instead.

Sebastian Markbage committed Jan 25, 2017 at 17:50 UTC 975ad92e68781aaa5fce215e73496781799e9c3c
3 files changed +46 -1
scripts/fiber/tests-passing.txt
+1
@@ -1145,6 +1145,7 @@ src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
1145 * should render a coroutine
1146 * should update a coroutine
1147 * should unmount a composite in a coroutine
1148 +* should handle deep updates in coroutine
1149
1150 src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
1151 * should render a simple component
src/renderers/shared/fiber/ReactFiberBeginWork.js
+4 -1
@@ -516,7 +516,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
516 }
517 }
518 } else if (nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine) {
519 - return bailoutOnAlreadyFinishedWork(current, workInProgress);
519 + nextCoroutine = workInProgress.memoizedProps;
520 + // TODO: When bailing out, we might need to return the stateNode instead
521 + // of the child. To check it for work.
522 + // return bailoutOnAlreadyFinishedWork(current, workInProgress);
523 }
524
525 const nextChildren = nextCoroutine.children;
src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
+41
@@ -224,4 +224,45 @@ describe('ReactCoroutine', () => {
224 ]);
225
226 });
227 +
228 + it('should handle deep updates in coroutine', () => {
229 + let instances = {};
230 +
231 + class Counter extends React.Component {
232 + state = {value: 5};
233 + render() {
234 + instances[this.props.id] = this;
235 + return ReactCoroutine.createYield(this.state.value);
236 + }
237 + }
238 +
239 + function App(props) {
240 + return ReactCoroutine.createCoroutine(
241 + [
242 + <Counter id="a" />,
243 + <Counter id="b" />,
244 + <Counter id="c" />,
245 + ],
246 + (p, yields) => yields.map(y => <span prop={y * 100} />),
247 + {}
248 + );
249 + }
250 +
251 + ReactNoop.render(<App />);
252 + ReactNoop.flush();
253 + expect(ReactNoop.getChildren()).toEqual([
254 + span(500),
255 + span(500),
256 + span(500),
257 + ]);
258 +
259 + instances.a.setState({value: 1});
260 + instances.b.setState({value: 2});
261 + ReactNoop.flush();
262 + expect(ReactNoop.getChildren()).toEqual([
263 + span(100),
264 + span(200),
265 + span(500),
266 + ]);
267 + });
268 });