Reconcile Call component children with current (#11979)

* Add test for un- and remounting children of Call

* Reconcile Call component children with `current`
This commit is contained in:
Reinier Hartog
2018-01-07 20:15:05 +00:00
committed by Dan Abramov
parent 52b83ecce3
commit 2172d770fc
2 changed files with 63 additions and 1 deletions
@@ -255,4 +255,66 @@ describe('ReactCallReturn', () => {
ReactNoop.flush();
expect(ReactNoop.getChildren()).toEqual([span(100), span(200), span(500)]);
});
it('should unmount and remount children', () => {
let ops = [];
class Call extends React.Component {
render() {
return ReactCallReturn.unstable_createCall(
this.props.children,
(p, returns) => returns,
{},
);
}
}
class Return extends React.Component {
render() {
ops.push(`Return ${this.props.value}`);
return ReactCallReturn.unstable_createReturn(this.props.children);
}
componentWillMount() {
ops.push(`Mount Return ${this.props.value}`);
}
componentWillUnmount() {
ops.push(`Unmount Return ${this.props.value}`);
}
}
ReactNoop.render(
<Call>
<Return value={1} />
<Return value={2} />
</Call>,
);
ReactNoop.flush();
expect(ops).toEqual([
'Mount Return 1',
'Return 1',
'Mount Return 2',
'Return 2',
]);
ops = [];
ReactNoop.render(<Call />);
ReactNoop.flush();
expect(ops).toEqual(['Unmount Return 1', 'Unmount Return 2']);
ops = [];
ReactNoop.render(
<Call>
<Return value={3} />
</Call>,
);
ReactNoop.flush();
expect(ops).toEqual(['Mount Return 3', 'Return 3']);
});
});
+1 -1
View File
@@ -559,7 +559,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
} else {
workInProgress.stateNode = reconcileChildFibers(
workInProgress,
workInProgress.stateNode,
current.stateNode,
nextChildren,
renderExpirationTime,
);