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.
Andrew Clark committed
Feb 27, 2017 at 15:54 UTC
81eef12507cc49dae1f70e44cea5493295eb69cd
1 file changed
+35
src/renderers/__tests__/ReactUpdates-test.js
+35
@@ -1189,4 +1189,39 @@ describe('ReactUpdates', () => {
1189
instance.setState(() => null);
1190
expect(ops).toEqual([]);
1191
});
1192
+
1193
+ // Will change once we switch to async by default
1194
+ it('synchronously renders hidden subtrees', () => {
1195
+ let container = document.createElement('div');
1196
+ let ops = [];
1197
+
1198
+ function Baz() {
1199
+ ops.push('Baz');
1200
+ return null;
1201
+ }
1202
+
1203
+ function Bar() {
1204
+ ops.push('Bar');
1205
+ return null;
1206
+ }
1207
+
1208
+ function Foo() {
1209
+ ops.push('Foo');
1210
+ return (
1211
+ <div>
1212
+ <div hidden={true}><Bar /></div>
1213
+ <Baz />
1214
+ </div>
1215
+ );
1216
+ }
1217
+
1218
+ // Mount
1219
+ ReactDOM.render(<Foo />, container);
1220
+ expect(ops).toEqual(['Foo', 'Bar', 'Baz']);
1221
+ ops = [];
1222
+
1223
+ // Update
1224
+ ReactDOM.render(<Foo />, container);
1225
+ expect(ops).toEqual(['Foo', 'Bar', 'Baz']);
1226
+ });
1227
});