@samitouri / QOS-React / commits / 08c86dd76b

Reconcile Call component children with `current` (#11979)

* Add test for un- and remounting children of Call * Reconcile Call component children with `current`

Reinier Hartog committed Jan 7, 2018 at 21:15 UTC 08c86dd76b8cdde2805c72a7609cc0b0c264a71e
2 files changed +63 -1
packages/react-call-return/src/__tests__/ReactCallReturn-test.js
+62
@@ -255,4 +255,66 @@ describe('ReactCallReturn', () => {
255 ReactNoop.flush();
256 expect(ReactNoop.getChildren()).toEqual([span(100), span(200), span(500)]);
257 });
258 +
259 + it('should unmount and remount children', () => {
260 + let ops = [];
261 +
262 + class Call extends React.Component {
263 + render() {
264 + return ReactCallReturn.unstable_createCall(
265 + this.props.children,
266 + (p, returns) => returns,
267 + {},
268 + );
269 + }
270 + }
271 +
272 + class Return extends React.Component {
273 + render() {
274 + ops.push(`Return ${this.props.value}`);
275 + return ReactCallReturn.unstable_createReturn(this.props.children);
276 + }
277 +
278 + componentWillMount() {
279 + ops.push(`Mount Return ${this.props.value}`);
280 + }
281 +
282 + componentWillUnmount() {
283 + ops.push(`Unmount Return ${this.props.value}`);
284 + }
285 + }
286 +
287 + ReactNoop.render(
288 + <Call>
289 + <Return value={1} />
290 + <Return value={2} />
291 + </Call>,
292 + );
293 + ReactNoop.flush();
294 +
295 + expect(ops).toEqual([
296 + 'Mount Return 1',
297 + 'Return 1',
298 + 'Mount Return 2',
299 + 'Return 2',
300 + ]);
301 +
302 + ops = [];
303 +
304 + ReactNoop.render(<Call />);
305 + ReactNoop.flush();
306 +
307 + expect(ops).toEqual(['Unmount Return 1', 'Unmount Return 2']);
308 +
309 + ops = [];
310 +
311 + ReactNoop.render(
312 + <Call>
313 + <Return value={3} />
314 + </Call>,
315 + );
316 + ReactNoop.flush();
317 +
318 + expect(ops).toEqual(['Mount Return 3', 'Return 3']);
319 + });
320 });
packages/react-reconciler/src/ReactFiberBeginWork.js
+1 -1
@@ -559,7 +559,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
559 } else {
560 workInProgress.stateNode = reconcileChildFibers(
561 workInProgress,
562 - workInProgress.stateNode,
562 + current.stateNode,
563 nextChildren,
564 renderExpirationTime,
565 );