mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Test that hidden subtrees render/update synchronously
When useSyncScheduling is set to true (as it is in the DOM renderer), we shouldn't give OffscreenPriority to hidden subtrees. Everything should be sync/task.
This commit is contained in:
committed by
Andrew Clark
parent
0585ee8b22
commit
81eef12507
@@ -1189,4 +1189,39 @@ describe('ReactUpdates', () => {
|
||||
instance.setState(() => null);
|
||||
expect(ops).toEqual([]);
|
||||
});
|
||||
|
||||
// Will change once we switch to async by default
|
||||
it('synchronously renders hidden subtrees', () => {
|
||||
let container = document.createElement('div');
|
||||
let ops = [];
|
||||
|
||||
function Baz() {
|
||||
ops.push('Baz');
|
||||
return null;
|
||||
}
|
||||
|
||||
function Bar() {
|
||||
ops.push('Bar');
|
||||
return null;
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
ops.push('Foo');
|
||||
return (
|
||||
<div>
|
||||
<div hidden={true}><Bar /></div>
|
||||
<Baz />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Mount
|
||||
ReactDOM.render(<Foo />, container);
|
||||
expect(ops).toEqual(['Foo', 'Bar', 'Baz']);
|
||||
ops = [];
|
||||
|
||||
// Update
|
||||
ReactDOM.render(<Foo />, container);
|
||||
expect(ops).toEqual(['Foo', 'Bar', 'Baz']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user