Add stable concurrent option to react-test-renderer (#27804)
## Summary Concurrent rendering has been the default since React 18 release. ReactTestRenderer requires passing `{unstable_isConcurrent: true}` to match this behavior, which means by default tests written with RTR use a different rendering method than the code they test. Eventually, RTR should only use ConcurrentRoot. As a first step, let's add a version of the concurrent option that isn't marked unstable. Next we will follow up with removing the unstable option when it is safe to merge. ## How did you test this change? `yarn test packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js`
Jack Pope committed
Dec 7, 2023 at 10:26 UTC
b36ae8d7aab94dae285d9d6a1c5f004e6fc19fc9
15 files changed
+107
-103
packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js
+7
-7
@@ -121,7 +121,7 @@ describe('ReactCache', () => {
121
}
122
123
ReactTestRenderer.create(<App />, {
124
- unstable_isConcurrent: true,
124
+ isConcurrent: true,
125
});
126
127
await waitForAll(['Suspend! [Hi]', 'Loading...']);
@@ -141,7 +141,7 @@ describe('ReactCache', () => {
141
}
142
143
const root = ReactTestRenderer.create(<App />, {
144
- unstable_isConcurrent: true,
144
+ isConcurrent: true,
145
});
146
147
await waitForAll(['Suspend! [Hi]', 'Loading...']);
@@ -181,7 +181,7 @@ describe('ReactCache', () => {
181
<App />
182
</Suspense>,
183
{
184
- unstable_isConcurrent: true,
184
+ isConcurrent: true,
185
},
186
);
187
@@ -210,7 +210,7 @@ describe('ReactCache', () => {
210
<AsyncText ms={100} text={3} />
211
</Suspense>,
212
{
213
- unstable_isConcurrent: true,
213
+ isConcurrent: true,
214
},
215
);
216
await waitForAll(['Suspend! [1]', 'Loading...']);
@@ -298,7 +298,7 @@ describe('ReactCache', () => {
298
<App />
299
</Suspense>,
300
{
301
- unstable_isConcurrent: true,
301
+ isConcurrent: true,
302
},
303
);
304
@@ -356,7 +356,7 @@ describe('ReactCache', () => {
356
<BadAsyncText text="Hi" />
357
</Suspense>,
358
{
359
- unstable_isConcurrent: true,
359
+ isConcurrent: true,
360
},
361
);
362
@@ -372,7 +372,7 @@ describe('ReactCache', () => {
372
<BadAsyncText text="Hi" />
373
</Suspense>,
374
{
375
- unstable_isConcurrent: true,
375
+ isConcurrent: true,
376
},
377
);
378
packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js
+1
-1
@@ -254,7 +254,7 @@ describe('React hooks DevTools integration', () => {
254
<MyComponent />
255
</React.Suspense>
256
</div>,
257
- {unstable_isConcurrent: true},
257
+ {isConcurrent: true},
258
),
259
);
260
packages/react-devtools-shared/src/__tests__/inspectedElement-test.js
+6
-6
@@ -75,7 +75,7 @@ describe('InspectedElement', () => {
75
// Used by inspectElementAtIndex() helper function
76
utils.act(() => {
77
testRendererInstance = TestRenderer.create(null, {
78
- unstable_isConcurrent: true,
78
+ isConcurrent: true,
79
});
80
});
81
@@ -307,7 +307,7 @@ describe('InspectedElement', () => {
307
['An update to %s inside a test was not wrapped in act'],
308
() => {
309
testRendererInstance = TestRenderer.create(null, {
310
- unstable_isConcurrent: true,
310
+ isConcurrent: true,
311
});
312
},
313
);
@@ -469,7 +469,7 @@ describe('InspectedElement', () => {
469
['An update to %s inside a test was not wrapped in act'],
470
() => {
471
testRendererInstance = TestRenderer.create(null, {
472
- unstable_isConcurrent: true,
472
+ isConcurrent: true,
473
});
474
},
475
);
@@ -2034,7 +2034,7 @@ describe('InspectedElement', () => {
2034
['An update to %s inside a test was not wrapped in act'],
2035
() => {
2036
testRendererInstance = TestRenderer.create(null, {
2037
- unstable_isConcurrent: true,
2037
+ isConcurrent: true,
2038
});
2039
},
2040
);
@@ -2317,7 +2317,7 @@ describe('InspectedElement', () => {
2317
<Suspender target={id} />
2318
</React.Suspense>
2319
</Contexts>,
2320
- {unstable_isConcurrent: true},
2320
+ {isConcurrent: true},
2321
);
2322
}, false);
2323
await utils.actAsync(() => {
@@ -2817,7 +2817,7 @@ describe('InspectedElement', () => {
2817
['An update to %s inside a test was not wrapped in act'],
2818
() => {
2819
testRendererInstance = TestRenderer.create(null, {
2820
- unstable_isConcurrent: true,
2820
+ isConcurrent: true,
2821
});
2822
},
2823
);
packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js
+9
-9
@@ -67,7 +67,7 @@ describe('DebugTracing', () => {
67
<React.unstable_DebugTracingMode>
68
<div />
69
</React.unstable_DebugTracingMode>,
70
- {unstable_isConcurrent: true},
70
+ {isConcurrent: true},
71
),
72
);
73
expect(logs).toEqual([]);
@@ -179,7 +179,7 @@ describe('DebugTracing', () => {
179
<Example />
180
</React.Suspense>
181
</React.unstable_DebugTracingMode>,
182
- {unstable_isConcurrent: true},
182
+ {isConcurrent: true},
183
),
184
);
185
@@ -216,7 +216,7 @@ describe('DebugTracing', () => {
216
</React.Suspense>
217
</Wrapper>
218
</React.unstable_DebugTracingMode>,
219
- {unstable_isConcurrent: true},
219
+ {isConcurrent: true},
220
),
221
);
222
@@ -247,7 +247,7 @@ describe('DebugTracing', () => {
247
<React.unstable_DebugTracingMode>
248
<Example />
249
</React.unstable_DebugTracingMode>,
250
- {unstable_isConcurrent: true},
250
+ {isConcurrent: true},
251
),
252
);
253
@@ -278,7 +278,7 @@ describe('DebugTracing', () => {
278
<React.unstable_DebugTracingMode>
279
<Example />
280
</React.unstable_DebugTracingMode>,
281
- {unstable_isConcurrent: true},
281
+ {isConcurrent: true},
282
),
283
);
284
}).toErrorDev('Cannot update during an existing state transition');
@@ -305,7 +305,7 @@ describe('DebugTracing', () => {
305
<React.unstable_DebugTracingMode>
306
<Example />
307
</React.unstable_DebugTracingMode>,
308
- {unstable_isConcurrent: true},
308
+ {isConcurrent: true},
309
),
310
);
311
@@ -333,7 +333,7 @@ describe('DebugTracing', () => {
333
<React.unstable_DebugTracingMode>
334
<Example />
335
</React.unstable_DebugTracingMode>,
336
- {unstable_isConcurrent: true},
336
+ {isConcurrent: true},
337
);
338
});
339
expect(logs).toEqual([
@@ -358,7 +358,7 @@ describe('DebugTracing', () => {
358
<React.unstable_DebugTracingMode>
359
<Example />
360
</React.unstable_DebugTracingMode>,
361
- {unstable_isConcurrent: true},
361
+ {isConcurrent: true},
362
);
363
});
364
@@ -381,7 +381,7 @@ describe('DebugTracing', () => {
381
<React.unstable_DebugTracingMode>
382
<Example />
383
</React.unstable_DebugTracingMode>,
384
- {unstable_isConcurrent: true},
384
+ {isConcurrent: true},
385
),
386
);
387
packages/react-reconciler/src/__tests__/ErrorBoundaryReconciliation-test.internal.js
+1
-1
@@ -59,7 +59,7 @@ describe('ErrorBoundaryReconciliation', () => {
59
<ErrorBoundary fallbackTagName={fallbackTagName}>
60
<BrokenRender fail={false} />
61
</ErrorBoundary>,
62
- {unstable_isConcurrent: isConcurrent},
62
+ {isConcurrent: isConcurrent},
63
);
64
});
65
expect(renderer).toMatchRenderedOutput(<span prop="BrokenRender" />);
packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
+8
-8
@@ -86,7 +86,7 @@ describe('ReactHooks', () => {
86
return <Child text={text} />;
87
}
88
89
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
89
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
90
root.update(<Parent />);
91
await waitForAll(['Parent: 0, 0', 'Child: 0, 0', 'Effect: 0, 0']);
92
expect(root).toMatchRenderedOutput('0, 0');
@@ -174,7 +174,7 @@ describe('ReactHooks', () => {
174
175
Parent = memo(Parent);
176
177
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
177
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
178
root.update(<Parent theme="light" />);
179
await waitForAll(['Parent: 0, 0 (light)', 'Child: 0, 0 (light)']);
180
expect(root).toMatchRenderedOutput('0, 0 (light)');
@@ -232,7 +232,7 @@ describe('ReactHooks', () => {
232
return counter;
233
}
234
235
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
235
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
236
root.update(<Counter />);
237
await waitForAll(['Count: 0']);
238
expect(root).toMatchRenderedOutput('0');
@@ -266,7 +266,7 @@ describe('ReactHooks', () => {
266
return counter;
267
}
268
269
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
269
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
270
root.update(<Counter />);
271
await waitForAll(['Count: 0']);
272
expect(root).toMatchRenderedOutput('0');
@@ -322,7 +322,7 @@ describe('ReactHooks', () => {
322
});
323
return <Child text={text} />;
324
}
325
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
325
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
326
await act(() => {
327
root.update(
328
<ThemeProvider>
@@ -390,7 +390,7 @@ describe('ReactHooks', () => {
390
return <Child text={counter} />;
391
}
392
393
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
393
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
394
root.update(<Parent />);
395
await waitForAll(['Parent: 0', 'Child: 0', 'Effect: 0']);
396
expect(root).toMatchRenderedOutput('0');
@@ -465,7 +465,7 @@ describe('ReactHooks', () => {
465
return <Child text={counter} />;
466
}
467
468
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
468
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
469
root.update(<Parent />);
470
await waitForAll(['Parent: 0', 'Child: 0']);
471
expect(root).toMatchRenderedOutput('0');
@@ -523,7 +523,7 @@ describe('ReactHooks', () => {
523
return <Child text={counter} />;
524
}
525
526
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
526
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
527
root.update(<Parent />);
528
await waitForAll(['Parent: 1', 'Child: 1']);
529
expect(root).toMatchRenderedOutput('1');
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
+25
-25
@@ -99,7 +99,7 @@ describe('ReactLazy', () => {
99
<LazyText text="Hi" />
100
</Suspense>,
101
{
102
- unstable_isConcurrent: true,
102
+ isConcurrent: true,
103
},
104
);
105
@@ -185,7 +185,7 @@ describe('ReactLazy', () => {
185
<LazyBar />
186
</Suspense>,
187
{
188
- unstable_isConcurrent: true,
188
+ isConcurrent: true,
189
},
190
);
191
@@ -208,7 +208,7 @@ describe('ReactLazy', () => {
208
const LazyText = lazy(async () => Text);
209
210
const root = ReactTestRenderer.create(null, {
211
- unstable_isConcurrent: true,
211
+ isConcurrent: true,
212
});
213
214
let error;
@@ -242,7 +242,7 @@ describe('ReactLazy', () => {
242
});
243
244
const root = ReactTestRenderer.create(null, {
245
- unstable_isConcurrent: true,
245
+ isConcurrent: true,
246
});
247
248
let error;
@@ -302,7 +302,7 @@ describe('ReactLazy', () => {
302
}
303
304
const root = ReactTestRenderer.create(<Parent swap={false} />, {
305
- unstable_isConcurrent: true,
305
+ isConcurrent: true,
306
});
307
308
await waitForAll(['Suspend! [LazyChildA]', 'Loading...']);
@@ -337,7 +337,7 @@ describe('ReactLazy', () => {
337
<LazyText />
338
</Suspense>,
339
{
340
- unstable_isConcurrent: true,
340
+ isConcurrent: true,
341
},
342
);
343
@@ -394,7 +394,7 @@ describe('ReactLazy', () => {
394
</Lazy>
395
</Suspense>,
396
{
397
- unstable_isConcurrent: true,
397
+ isConcurrent: true,
398
},
399
);
400
await waitForAll(['Loading...']);
@@ -440,7 +440,7 @@ describe('ReactLazy', () => {
440
</Suspense>
441
</>,
442
{
443
- unstable_isConcurrent: true,
443
+ isConcurrent: true,
444
},
445
);
446
await waitForAll(['Not lazy: 0', 'Loading...']);
@@ -485,7 +485,7 @@ describe('ReactLazy', () => {
485
</Suspense>
486
</>,
487
{
488
- unstable_isConcurrent: true,
488
+ isConcurrent: true,
489
},
490
);
491
await waitForAll(['Not lazy: 0', 'Loading...']);
@@ -561,7 +561,7 @@ describe('ReactLazy', () => {
561
<LazyClass num={1} />
562
</Suspense>,
563
{
564
- unstable_isConcurrent: true,
564
+ isConcurrent: true,
565
},
566
);
567
@@ -691,7 +691,7 @@ describe('ReactLazy', () => {
691
<LazyText />
692
</Suspense>,
693
{
694
- unstable_isConcurrent: true,
694
+ isConcurrent: true,
695
},
696
);
697
@@ -734,7 +734,7 @@ describe('ReactLazy', () => {
734
<BadLazy />
735
</Suspense>,
736
{
737
- unstable_isConcurrent: true,
737
+ isConcurrent: true,
738
},
739
);
740
@@ -761,7 +761,7 @@ describe('ReactLazy', () => {
761
<Lazy2 text="Hello" />
762
</Suspense>,
763
{
764
- unstable_isConcurrent: true,
764
+ isConcurrent: true,
765
},
766
);
767
@@ -815,7 +815,7 @@ describe('ReactLazy', () => {
815
<LazyAdd inner="2" outer="2" />
816
</Suspense>,
817
{
818
- unstable_isConcurrent: true,
818
+ isConcurrent: true,
819
},
820
);
821
@@ -1012,7 +1012,7 @@ describe('ReactLazy', () => {
1012
<LazyText />
1013
</Suspense>,
1014
{
1015
- unstable_isConcurrent: true,
1015
+ isConcurrent: true,
1016
},
1017
);
1018
@@ -1055,7 +1055,7 @@ describe('ReactLazy', () => {
1055
<LazyFoo />
1056
</Suspense>,
1057
{
1058
- unstable_isConcurrent: true,
1058
+ isConcurrent: true,
1059
},
1060
);
1061
@@ -1100,7 +1100,7 @@ describe('ReactLazy', () => {
1100
<LazyForwardRef ref={ref} />
1101
</Suspense>,
1102
{
1103
- unstable_isConcurrent: true,
1103
+ isConcurrent: true,
1104
},
1105
);
1106
@@ -1131,7 +1131,7 @@ describe('ReactLazy', () => {
1131
<LazyAdd outer={2} />
1132
</Suspense>,
1133
{
1134
- unstable_isConcurrent: true,
1134
+ isConcurrent: true,
1135
},
1136
);
1137
await waitForAll(['Loading...']);
@@ -1218,7 +1218,7 @@ describe('ReactLazy', () => {
1218
<LazyAdd outer={2} />
1219
</Suspense>,
1220
{
1221
- unstable_isConcurrent: true,
1221
+ isConcurrent: true,
1222
},
1223
);
1224
await waitForAll(['Loading...']);
@@ -1264,7 +1264,7 @@ describe('ReactLazy', () => {
1264
<LazyFoo ref={ref} />
1265
</Suspense>,
1266
{
1267
- unstable_isConcurrent: true,
1267
+ isConcurrent: true,
1268
},
1269
);
1270
@@ -1304,7 +1304,7 @@ describe('ReactLazy', () => {
1304
<LazyText text="Hi" />
1305
</Suspense>
1306
</ErrorBoundary>,
1307
- {unstable_isConcurrent: true},
1307
+ {isConcurrent: true},
1308
);
1309
1310
await waitForAll(['Loading...']);
@@ -1412,7 +1412,7 @@ describe('ReactLazy', () => {
1412
}
1413
1414
const root = ReactTestRenderer.create(<Parent swap={false} />, {
1415
- unstable_isConcurrent: true,
1415
+ isConcurrent: true,
1416
});
1417
1418
await waitForAll(['Init A', 'Loading...']);
@@ -1497,7 +1497,7 @@ describe('ReactLazy', () => {
1497
}
1498
1499
const root = ReactTestRenderer.create(<Parent swap={false} />, {
1500
- unstable_isConcurrent: false,
1500
+ isConcurrent: false,
1501
});
1502
1503
assertLog(['Init A', 'Init B', 'Loading...']);
@@ -1559,7 +1559,7 @@ describe('ReactLazy', () => {
1559
}
1560
1561
const root = ReactTestRenderer.create(<Parent swap={false} />, {
1562
- unstable_isConcurrent: true,
1562
+ isConcurrent: true,
1563
});
1564
1565
await waitForAll(['Init A', 'Loading...']);
@@ -1628,7 +1628,7 @@ describe('ReactLazy', () => {
1628
}
1629
1630
const root = ReactTestRenderer.create(<Parent swap={false} />, {
1631
- unstable_isConcurrent: false,
1631
+ isConcurrent: false,
1632
});
1633
1634
assertLog(['Init A', 'Loading...']);
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+13
-13
@@ -117,7 +117,7 @@ describe('ReactSuspense', () => {
117
118
// Render an empty shell
119
const root = ReactTestRenderer.create(<Foo />, {
120
- unstable_isConcurrent: true,
120
+ isConcurrent: true,
121
});
122
123
await waitForAll(['Foo']);
@@ -158,7 +158,7 @@ describe('ReactSuspense', () => {
158
</Suspense>
159
</>,
160
{
161
- unstable_isConcurrent: true,
161
+ isConcurrent: true,
162
},
163
);
164
@@ -217,7 +217,7 @@ describe('ReactSuspense', () => {
217
<Text text="Initial" />
218
</>,
219
{
220
- unstable_isConcurrent: true,
220
+ isConcurrent: true,
221
},
222
);
223
await waitForAll(['Initial']);
@@ -268,7 +268,7 @@ describe('ReactSuspense', () => {
268
}
269
270
const root = ReactTestRenderer.create(<Foo />, {
271
- unstable_isConcurrent: true,
271
+ isConcurrent: true,
272
});
273
274
await waitForAll(['Foo', 'Suspend! [A]', 'Loading...']);
@@ -303,7 +303,7 @@ describe('ReactSuspense', () => {
303
}
304
305
const root = ReactTestRenderer.create(<Foo />, {
306
- unstable_isConcurrent: true,
306
+ isConcurrent: true,
307
});
308
309
await waitForAll(['Foo', 'Suspend! [A]', 'Loading...']);
@@ -353,7 +353,7 @@ describe('ReactSuspense', () => {
353
}
354
355
const root = ReactTestRenderer.create(null, {
356
- unstable_isConcurrent: true,
356
+ isConcurrent: true,
357
});
358
359
root.update(<App shouldSuspend={false} step={0} />);
@@ -456,7 +456,7 @@ describe('ReactSuspense', () => {
456
}
457
458
const root = ReactTestRenderer.create(<App />, {
459
- unstable_isConcurrent: true,
459
+ isConcurrent: true,
460
});
461
await waitForAll(['Suspend! [default]', 'Loading...']);
462
@@ -502,7 +502,7 @@ describe('ReactSuspense', () => {
502
}
503
504
const root = ReactTestRenderer.create(<App />, {
505
- unstable_isConcurrent: true,
505
+ isConcurrent: true,
506
});
507
await waitForAll(['Suspend! [default]', 'Loading...']);
508
@@ -545,7 +545,7 @@ describe('ReactSuspense', () => {
545
</Suspense>
546
</App>,
547
{
548
- unstable_isConcurrent: true,
548
+ isConcurrent: true,
549
},
550
);
551
await waitForAll(['Suspend! [default]', 'Loading...']);
@@ -589,7 +589,7 @@ describe('ReactSuspense', () => {
589
</Suspense>
590
</App>,
591
{
592
- unstable_isConcurrent: true,
592
+ isConcurrent: true,
593
},
594
);
595
await waitForAll(['Suspend! [default]', 'Loading...']);
@@ -631,7 +631,7 @@ describe('ReactSuspense', () => {
631
}
632
633
const root = ReactTestRenderer.create(<App />, {
634
- unstable_isConcurrent: true,
634
+ isConcurrent: true,
635
});
636
637
await waitForAll(['Child 1', 'create layout']);
@@ -899,7 +899,7 @@ describe('ReactSuspense', () => {
899
}
900
901
const root = ReactTestRenderer.create(<App />, {
902
- unstable_isConcurrent: true,
902
+ isConcurrent: true,
903
});
904
905
// Initial render
@@ -990,7 +990,7 @@ describe('ReactSuspense', () => {
990
}
991
992
const root = ReactTestRenderer.create(<App />, {
993
- unstable_isConcurrent: true,
993
+ isConcurrent: true,
994
});
995
996
await waitForAll(['Suspend! [Child 1]', 'Loading...']);
packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js
+11
-11
@@ -76,7 +76,7 @@ describe('StrictEffectsMode', () => {
76
let renderer;
77
await act(() => {
78
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
79
- unstable_isConcurrent: true,
79
+ isConcurrent: true,
80
});
81
});
82
@@ -129,7 +129,7 @@ describe('StrictEffectsMode', () => {
129
let renderer;
130
await act(() => {
131
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
132
- unstable_isConcurrent: true,
132
+ isConcurrent: true,
133
});
134
});
135
@@ -182,7 +182,7 @@ describe('StrictEffectsMode', () => {
182
let renderer;
183
await act(() => {
184
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
185
- unstable_isConcurrent: true,
185
+ isConcurrent: true,
186
});
187
});
188
@@ -233,7 +233,7 @@ describe('StrictEffectsMode', () => {
233
let renderer;
234
await act(() => {
235
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
236
- unstable_isConcurrent: true,
236
+ isConcurrent: true,
237
});
238
});
239
@@ -286,7 +286,7 @@ describe('StrictEffectsMode', () => {
286
}
287
288
await act(() => {
289
- ReactTestRenderer.create(<App />, {unstable_isConcurrent: true});
289
+ ReactTestRenderer.create(<App />, {isConcurrent: true});
290
});
291
292
if (supportsDoubleInvokeEffects()) {
@@ -322,7 +322,7 @@ describe('StrictEffectsMode', () => {
322
let renderer;
323
await act(() => {
324
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
325
- unstable_isConcurrent: true,
325
+ isConcurrent: true,
326
});
327
});
328
@@ -367,7 +367,7 @@ describe('StrictEffectsMode', () => {
367
let renderer;
368
await act(() => {
369
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
370
- unstable_isConcurrent: true,
370
+ isConcurrent: true,
371
});
372
});
373
@@ -438,7 +438,7 @@ describe('StrictEffectsMode', () => {
438
439
await act(() => {
440
ReactTestRenderer.create(<App text={'mount'} />, {
441
- unstable_isConcurrent: true,
441
+ isConcurrent: true,
442
});
443
});
444
@@ -502,7 +502,7 @@ describe('StrictEffectsMode', () => {
502
}
503
504
await act(() => {
505
- ReactTestRenderer.create(<App />, {unstable_isConcurrent: true});
505
+ ReactTestRenderer.create(<App />, {isConcurrent: true});
506
});
507
508
if (supportsDoubleInvokeEffects()) {
@@ -586,7 +586,7 @@ describe('StrictEffectsMode', () => {
586
let renderer;
587
await act(() => {
588
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
589
- unstable_isConcurrent: true,
589
+ isConcurrent: true,
590
});
591
});
592
@@ -667,7 +667,7 @@ describe('StrictEffectsMode', () => {
667
let renderer;
668
await act(() => {
669
renderer = ReactTestRenderer.create(<App text={'mount'} />, {
670
- unstable_isConcurrent: true,
670
+ isConcurrent: true,
671
});
672
});
673
packages/react-test-renderer/src/ReactTestRenderer.js
+5
-1
@@ -60,6 +60,7 @@ const act = React.unstable_act;
60
61
type TestRendererOptions = {
62
createNodeMock: (element: React$Element<any>) => any,
63
+ isConcurrent: boolean,
64
unstable_isConcurrent: boolean,
65
unstable_strictMode: boolean,
66
unstable_concurrentUpdatesByDefault: boolean,
@@ -479,7 +480,10 @@ function create(
480
// $FlowFixMe[incompatible-type] found when upgrading Flow
481
createNodeMock = options.createNodeMock;
482
}
482
- if (options.unstable_isConcurrent === true) {
483
+ if (
484
+ options.unstable_isConcurrent === true ||
485
+ options.isConcurrent === true
486
+ ) {
487
isConcurrent = true;
488
}
489
if (options.unstable_strictMode === true) {
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js
+4
-4
@@ -34,7 +34,7 @@ describe('ReactTestRendererAsync', () => {
34
return props.children;
35
}
36
const renderer = ReactTestRenderer.create(<Foo>Hi</Foo>, {
37
- unstable_isConcurrent: true,
37
+ isConcurrent: true,
38
});
39
40
// Before flushing, nothing has mounted.
@@ -68,7 +68,7 @@ describe('ReactTestRendererAsync', () => {
68
);
69
}
70
const renderer = ReactTestRenderer.create(<Parent step={1} />, {
71
- unstable_isConcurrent: true,
71
+ isConcurrent: true,
72
});
73
74
await waitForAll(['A:1', 'B:1', 'C:1']);
@@ -97,7 +97,7 @@ describe('ReactTestRendererAsync', () => {
97
let renderer;
98
React.startTransition(() => {
99
renderer = ReactTestRenderer.create(<Parent step={1} />, {
100
- unstable_isConcurrent: true,
100
+ isConcurrent: true,
101
});
102
});
103
@@ -137,7 +137,7 @@ describe('ReactTestRendererAsync', () => {
137
let renderer;
138
React.startTransition(() => {
139
renderer = ReactTestRenderer.create(<Example step={1} />, {
140
- unstable_isConcurrent: true,
140
+ isConcurrent: true,
141
});
142
});
143
packages/react/src/__tests__/ReactProfiler-test.internal.js
+6
-6
@@ -213,7 +213,7 @@ describe(`onRender`, () => {
213
<Yield value="last" />
214
</React.Profiler>,
215
{
216
- unstable_isConcurrent: true,
216
+ isConcurrent: true,
217
},
218
);
219
});
@@ -752,7 +752,7 @@ describe(`onRender`, () => {
752
<Yield renderTime={2} />
753
<Yield renderTime={3} />
754
</React.Profiler>,
755
- {unstable_isConcurrent: true},
755
+ {isConcurrent: true},
756
);
757
});
758
@@ -793,7 +793,7 @@ describe(`onRender`, () => {
793
<Yield renderTime={17} />
794
</React.Profiler>
795
</React.Profiler>,
796
- {unstable_isConcurrent: true},
796
+ {isConcurrent: true},
797
);
798
});
799
@@ -844,7 +844,7 @@ describe(`onRender`, () => {
844
<Yield renderTime={10} />
845
<Yield renderTime={20} />
846
</React.Profiler>,
847
- {unstable_isConcurrent: true},
847
+ {isConcurrent: true},
848
);
849
});
850
@@ -897,7 +897,7 @@ describe(`onRender`, () => {
897
<Yield renderTime={6} />
898
<Yield renderTime={15} />
899
</React.Profiler>,
900
- {unstable_isConcurrent: true},
900
+ {isConcurrent: true},
901
);
902
903
// Render everything initially.
@@ -1002,7 +1002,7 @@ describe(`onRender`, () => {
1002
<FirstComponent />
1003
<SecondComponent />
1004
</React.Profiler>,
1005
- {unstable_isConcurrent: true},
1005
+ {isConcurrent: true},
1006
);
1007
1008
// Render everything initially.
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+1
-1
@@ -150,7 +150,7 @@ describe('ReactProfiler DevTools integration', () => {
150
return text;
151
}
152
153
- const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
153
+ const root = ReactTestRenderer.create(null, {isConcurrent: true});
154
155
// Commit something
156
root.update(<Text text="A" />);
packages/react/src/__tests__/ReactStartTransition-test.js
+1
-1
@@ -49,7 +49,7 @@ describe('ReactStartTransition', () => {
49
50
await act(() => {
51
ReactTestRenderer.create(<Component level={0} />, {
52
- unstable_isConcurrent: true,
52
+ isConcurrent: true,
53
});
54
});
55
packages/use-subscription/src/__tests__/useSubscription-test.js
+9
-9
@@ -84,7 +84,7 @@ describe('useSubscription', () => {
84
await act(() => {
85
renderer = ReactTestRenderer.create(
86
<Subscription source={observable} />,
87
- {unstable_isConcurrent: true},
87
+ {isConcurrent: true},
88
);
89
});
90
assertLog(['default']);
@@ -136,7 +136,7 @@ describe('useSubscription', () => {
136
await act(() => {
137
renderer = ReactTestRenderer.create(
138
<Subscription source={observable} />,
139
- {unstable_isConcurrent: true},
139
+ {isConcurrent: true},
140
);
141
});
142
assertLog(['initial']);
@@ -185,7 +185,7 @@ describe('useSubscription', () => {
185
await act(() => {
186
renderer = ReactTestRenderer.create(
187
<Subscription source={observableA} />,
188
- {unstable_isConcurrent: true},
188
+ {isConcurrent: true},
189
);
190
});
191
@@ -244,7 +244,7 @@ describe('useSubscription', () => {
244
await act(() => {
245
renderer = ReactTestRenderer.create(
246
<Subscription source={observableA} />,
247
- {unstable_isConcurrent: true},
247
+ {isConcurrent: true},
248
);
249
});
250
@@ -331,7 +331,7 @@ describe('useSubscription', () => {
331
let renderer;
332
await act(() => {
333
renderer = ReactTestRenderer.create(<Parent observed={observableA} />, {
334
- unstable_isConcurrent: true,
334
+ isConcurrent: true,
335
});
336
});
337
assertLog(['Child: a-0', 'Grandchild: a-0']);
@@ -434,7 +434,7 @@ describe('useSubscription', () => {
434
let renderer;
435
await act(() => {
436
renderer = ReactTestRenderer.create(<Parent observed={observableA} />, {
437
- unstable_isConcurrent: true,
437
+ isConcurrent: true,
438
});
439
});
440
assertLog(['Child: a-0', 'Grandchild: a-0']);
@@ -532,7 +532,7 @@ describe('useSubscription', () => {
532
await act(() => {
533
renderer = ReactTestRenderer.create(
534
<Subscription source={eventHandler} />,
535
- {unstable_isConcurrent: true},
535
+ {isConcurrent: true},
536
);
537
});
538
assertLog([true]);
@@ -566,7 +566,7 @@ describe('useSubscription', () => {
566
await act(() => {
567
renderer = ReactTestRenderer.create(
568
<Subscription subscription={subscription1} />,
569
- {unstable_isConcurrent: true},
569
+ {isConcurrent: true},
570
);
571
});
572
await waitForAll([]);
@@ -607,7 +607,7 @@ describe('useSubscription', () => {
607
<Subscriber id="first" />
608
<Subscriber id="second" />
609
</React.Fragment>,
610
- {unstable_isConcurrent: true},
610
+ {isConcurrent: true},
611
);
612
await waitForAll(['render:first:A', 'render:second:A']);
613