Skip to content

Commit 975ad92

Browse files
committed
Don't bail to .child of coroutines
This should bail to stateNode instead.
1 parent 754f72a commit 975ad92

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

scripts/fiber/tests-passing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
11451145
* should render a coroutine
11461146
* should update a coroutine
11471147
* should unmount a composite in a coroutine
1148+
* should handle deep updates in coroutine
11481149

11491150
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
11501151
* should render a simple component

src/renderers/shared/fiber/ReactFiberBeginWork.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
516516
}
517517
}
518518
} 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);
520523
}
521524

522525
const nextChildren = nextCoroutine.children;

src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,45 @@ describe('ReactCoroutine', () => {
224224
]);
225225

226226
});
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+
});
227268
});

0 commit comments

Comments
 (0)