79
});
80
assertConsoleErrorDev([
81
'"something" is not a supported revealOrder on ' +
82
- '<SuspenseList />. Did you mean "together", "forwards" or "backwards"?' +
82
+ '<SuspenseList />. Did you mean "independent", "together", "forwards" or "backwards"?' +
83
'\n in SuspenseList (at **)' +
84
'\n in Foo (at **)',
85
]);
131
// @gate enableSuspenseList
132
it('warns if a single element is passed to a "forwards" list', async () => {
133
function Foo({children}) {
134
- return <SuspenseList revealOrder="forwards">{children}</SuspenseList>;
134
+ return (
135
+ <SuspenseList revealOrder="forwards" tail="visible">
136
+ {children}
137
+ </SuspenseList>
138
+ );
139
}
140
141
ReactNoop.render(<Foo />);
170
it('warns if a single fragment is passed to a "backwards" list', async () => {
171
function Foo() {
172
return (
169
- <SuspenseList revealOrder="backwards">
173
+ <SuspenseList revealOrder="unstable_legacy-backwards" tail="visible">
174
<>{[]}</>
175
</SuspenseList>
176
);
180
ReactNoop.render(<Foo />);
181
});
182
assertConsoleErrorDev([
179
- 'A single row was passed to a <SuspenseList revealOrder="backwards" />. ' +
183
+ 'A single row was passed to a <SuspenseList revealOrder="unstable_legacy-backwards" />. ' +
184
'This is not useful since it needs multiple rows. ' +
185
'Did you mean to pass multiple children or an array?' +
186
'\n in SuspenseList (at **)' +
192
it('warns if a nested array is passed to a "forwards" list', async () => {
193
function Foo({items}) {
194
return (
191
- <SuspenseList revealOrder="forwards">
195
+ <SuspenseList revealOrder="forwards" tail="visible">
196
{items.map(name => (
197
<Suspense key={name} fallback="Loading">
198
{name}
218
});
219
220
// @gate enableSuspenseList
217
- it('shows content independently by default', async () => {
221
+ it('warns if no revealOrder is specified', async () => {
222
const A = createAsyncText('A');
223
const B = createAsyncText('B');
224
const C = createAsyncText('C');
254
'Suspend! [C]',
255
]);
256
257
+ assertConsoleErrorDev([
258
+ 'The default for the <SuspenseList revealOrder="..."> prop is changing. ' +
259
+ 'To be future compatible you must explictly specify either ' +
260
+ '"independent" (the current default), "together", "forwards" or "legacy_unstable-backwards".' +
261
+ '\n in SuspenseList (at **)' +
262
+ '\n in Foo (at **)',
263
+ ]);
264
+
265
+ expect(ReactNoop).toMatchRenderedOutput(
266
+ <>
267
+ <span>A</span>
268
+ <span>Loading B</span>
269
+ <span>Loading C</span>
270
+ </>,
271
+ );
272
+
273
+ await act(() => C.resolve());
274
+ assertLog(
275
+ gate('alwaysThrottleRetries')
276
+ ? ['Suspend! [B]', 'C', 'Suspend! [B]']
277
+ : ['C'],
278
+ );
279
+
280
+ expect(ReactNoop).toMatchRenderedOutput(
281
+ <>
282
+ <span>A</span>
283
+ <span>Loading B</span>
284
+ <span>C</span>
285
+ </>,
286
+ );
287
+
288
+ await act(() => B.resolve());
289
+ assertLog(['B']);
290
+
291
+ expect(ReactNoop).toMatchRenderedOutput(
292
+ <>
293
+ <span>A</span>
294
+ <span>B</span>
295
+ <span>C</span>
296
+ </>,
297
+ );
298
+ });
299
+
300
+ // @gate enableSuspenseList
301
+ it('shows content independently with revealOrder="independent"', async () => {
302
+ const A = createAsyncText('A');
303
+ const B = createAsyncText('B');
304
+ const C = createAsyncText('C');
305
+
306
+ function Foo() {
307
+ return (
308
+ <SuspenseList revealOrder="independent">
309
+ <Suspense fallback={<Text text="Loading A" />}>
310
+ <A />
311
+ </Suspense>
312
+ <Suspense fallback={<Text text="Loading B" />}>
313
+ <B />
314
+ </Suspense>
315
+ <Suspense fallback={<Text text="Loading C" />}>
316
+ <C />
317
+ </Suspense>
318
+ </SuspenseList>
319
+ );
320
+ }
321
+
322
+ await A.resolve();
323
+
324
+ ReactNoop.render(<Foo />);
325
+
326
+ await waitForAll([
327
+ 'A',
328
+ 'Suspend! [B]',
329
+ 'Loading B',
330
+ 'Suspend! [C]',
331
+ 'Loading C',
332
+ // pre-warming
333
+ 'Suspend! [B]',
334
+ 'Suspend! [C]',
335
+ ]);
336
+
337
expect(ReactNoop).toMatchRenderedOutput(
338
<>
339
<span>A</span>
648
});
649
650
// @gate enableSuspenseList
567
- it('displays all "together" in nested SuspenseLists where the inner is default', async () => {
651
+ it('displays all "together" in nested SuspenseLists where the inner is "independent"', async () => {
652
const A = createAsyncText('A');
653
const B = createAsyncText('B');
654
const C = createAsyncText('C');
659
<Suspense fallback={<Text text="Loading A" />}>
660
<A />
661
</Suspense>
578
- <SuspenseList>
662
+ <SuspenseList revealOrder="independent">
663
<Suspense fallback={<Text text="Loading B" />}>
664
<B />
665
</Suspense>
981
982
function Foo() {
983
return (
900
- <SuspenseList revealOrder="forwards">
984
+ <SuspenseList revealOrder="forwards" tail="visible">
985
<Suspense fallback={<Text text="Loading A" />}>
986
<A />
987
</Suspense>
1039
);
1040
});
1041
1042
+ // @gate enableSuspenseList
1043
+ it('warns if revealOrder="backwards" is specified', async () => {
1044
+ const A = createAsyncText('A');
1045
+ const B = createAsyncText('B');
1046
+ const C = createAsyncText('C');
1047
+
1048
+ function Foo() {
1049
+ return (
1050
+ <SuspenseList revealOrder="backwards" tail="visible">
1051
+ <Suspense fallback={<Text text="Loading A" />}>
1052
+ <A />
1053
+ </Suspense>
1054
+ <Suspense fallback={<Text text="Loading B" />}>
1055
+ <B />
1056
+ </Suspense>
1057
+ <Suspense fallback={<Text text="Loading C" />}>
1058
+ <C />
1059
+ </Suspense>
1060
+ </SuspenseList>
1061
+ );
1062
+ }
1063
+
1064
+ await A.resolve();
1065
+
1066
+ ReactNoop.render(<Foo />);
1067
+
1068
+ await waitForAll([
1069
+ 'Suspend! [C]',
1070
+ 'Loading C',
1071
+ 'Loading B',
1072
+ 'Loading A',
1073
+ // pre-warming
1074
+ 'Suspend! [C]',
1075
+ ]);
1076
+
1077
+ assertConsoleErrorDev([
1078
+ 'The rendering order of <SuspenseList revealOrder="backwards"> is changing. ' +
1079
+ 'To be future compatible you must specify ' +
1080
+ 'revealOrder="legacy_unstable-backwards" instead.' +
1081
+ '\n in SuspenseList (at **)' +
1082
+ '\n in Foo (at **)',
1083
+ ]);
1084
+
1085
+ expect(ReactNoop).toMatchRenderedOutput(
1086
+ <>
1087
+ <span>Loading A</span>
1088
+ <span>Loading B</span>
1089
+ <span>Loading C</span>
1090
+ </>,
1091
+ );
1092
+
1093
+ await act(() => C.resolve());
1094
+ assertLog([
1095
+ 'C',
1096
+ 'Suspend! [B]',
1097
+ // pre-warming
1098
+ 'Suspend! [B]',
1099
+ ]);
1100
+
1101
+ expect(ReactNoop).toMatchRenderedOutput(
1102
+ <>
1103
+ <span>Loading A</span>
1104
+ <span>Loading B</span>
1105
+ <span>C</span>
1106
+ </>,
1107
+ );
1108
+
1109
+ await act(() => B.resolve());
1110
+ assertLog(['B', 'A']);
1111
+
1112
+ expect(ReactNoop).toMatchRenderedOutput(
1113
+ <>
1114
+ <span>A</span>
1115
+ <span>B</span>
1116
+ <span>C</span>
1117
+ </>,
1118
+ );
1119
+ });
1120
+
1121
// @gate enableSuspenseList
1122
it('displays each items in "backwards" order', async () => {
1123
const A = createAsyncText('A');
1126
1127
function Foo() {
1128
return (
966
- <SuspenseList revealOrder="backwards">
1129
+ <SuspenseList revealOrder="unstable_legacy-backwards" tail="visible">
1130
<Suspense fallback={<Text text="Loading A" />}>
1131
<A />
1132
</Suspense>
1200
1201
function Foo({items}) {
1202
return (
1040
- <SuspenseList revealOrder="forwards">
1203
+ <SuspenseList revealOrder="forwards" tail="visible">
1204
{items.map(([key, Component]) => (
1205
<Suspense key={key} fallback={<Text text={'Loading ' + key} />}>
1206
<Component />
1385
1386
function Foo({items}) {
1387
return (
1225
- <SuspenseList revealOrder="backwards">
1388
+ <SuspenseList revealOrder="unstable_legacy-backwards" tail="visible">
1389
{items.map(([key, Component]) => (
1390
<Suspense key={key} fallback={<Text text={'Loading ' + key} />}>
1391
<Component />
1563
it('switches to rendering fallbacks if the tail takes long CPU time', async () => {
1564
function Foo() {
1565
return (
1403
- <SuspenseList revealOrder="forwards">
1566
+ <SuspenseList revealOrder="forwards" tail="visible">
1567
<Suspense fallback={<Text text="Loading A" />}>
1568
<Text text="A" />
1569
</Suspense>
1698
);
1699
});
1700
1701
+ // @gate enableSuspenseList
1702
+ it('warns if no tail option is specified', async () => {
1703
+ function Foo() {
1704
+ return (
1705
+ <SuspenseList revealOrder="forwards">
1706
+ <Suspense fallback="Loading">A</Suspense>
1707
+ <Suspense fallback="Loading">B</Suspense>
1708
+ </SuspenseList>
1709
+ );
1710
+ }
1711
+
1712
+ await act(() => {
1713
+ ReactNoop.render(<Foo />);
1714
+ });
1715
+ assertConsoleErrorDev([
1716
+ 'The default for the <SuspenseList tail="..."> prop is changing. ' +
1717
+ 'To be future compatible you must explictly specify either ' +
1718
+ '"visible" (the current default), "collapsed" or "hidden".' +
1719
+ '\n in SuspenseList (at **)' +
1720
+ '\n in Foo (at **)',
1721
+ ]);
1722
+ });
1723
+
1724
// @gate enableSuspenseList
1725
it('warns if an unsupported tail option is used', async () => {
1726
function Foo() {
1737
});
1738
assertConsoleErrorDev([
1739
'"collapse" is not a supported value for tail on ' +
1554
- '<SuspenseList />. Did you mean "collapsed" or "hidden"?' +
1740
+ '<SuspenseList />. Did you mean "visible", "collapsed" or "hidden"?' +
1741
'\n in SuspenseList (at **)' +
1742
'\n in Foo (at **)',
1743
]);
1982
1983
function Foo({items}) {
1984
return (
1799
- <SuspenseList revealOrder="backwards" tail="collapsed">
1985
+ <SuspenseList revealOrder="unstable_legacy-backwards" tail="collapsed">
1986
{items.map(([key, Component]) => (
1987
<Suspense key={key} fallback={<Text text={'Loading ' + key} />}>
1988
<Component />
2340
function Foo() {
2341
return (
2342
<SuspenseList revealOrder="together">
2157
- <SuspenseList revealOrder="forwards">
2343
+ <SuspenseList revealOrder="forwards" tail="visible">
2344
<Suspense fallback={<Text text="Loading A" />}>
2345
<Text text="A" />
2346
</Suspense>
2441
2442
function Foo({showB}) {
2443
return (
2258
- <SuspenseList revealOrder="forwards">
2444
+ <SuspenseList revealOrder="forwards" tail="visible">
2445
<SuspenseList revealOrder="forwards" tail="hidden">
2446
<Suspense fallback={<Text text="Loading A" />}>
2447
<Text text="A" />
2507
function Foo() {
2508
return (
2509
<div>
2324
- <SuspenseList revealOrder="forwards">
2510
+ <SuspenseList revealOrder="forwards" tail="visible">
2511
<Text text="A" />
2512
<Text text="B" />
2513
</SuspenseList>
2859
function App() {
2860
Scheduler.log('App');
2861
return (
2676
- <SuspenseList revealOrder="forwards">
2862
+ <SuspenseList revealOrder="forwards" tail="visible">
2863
<Suspense fallback={<Text text="Loading A" />}>
2864
<Sleep time={600}>
2865
<TwoPass text="A" />
2946
Scheduler.log('App');
2947
return (
2948
<Profiler id="root" onRender={onRender}>
2763
- <SuspenseList revealOrder="forwards">
2949
+ <SuspenseList revealOrder="forwards" tail="visible">
2950
<Suspense fallback={<Fallback />}>
2951
<Sleep time={1}>
2952
<A />
3122
// Several layers of Bailout wrappers help verify we're
3123
// marking updates all the way to the propagation root.
3124
return (
2939
- <SuspenseList revealOrder="forwards">
3125
+ <SuspenseList revealOrder="forwards" tail="visible">
3126
<Bailout>
3127
<Bailout>
3128
<Bailout>
3215
3216
function Repro({update}) {
3217
return (
3032
- <SuspenseList revealOrder="forwards">
3218
+ <SuspenseList revealOrder="forwards" tail="visible">
3219
{update && (
3220
<Suspense fallback={<Text text="Loading A..." />}>
3221
<A />
3314
}
3315
function Foo() {
3316
return (
3131
- <SuspenseList revealOrder="forwards">
3317
+ <SuspenseList revealOrder="forwards" tail="visible">
3318
<Generator />
3319
</SuspenseList>
3320
);
3370
};
3371
3372
function Foo() {
3187
- return <SuspenseList revealOrder="forwards">{iterable}</SuspenseList>;
3373
+ return (
3374
+ <SuspenseList revealOrder="forwards" tail="visible">
3375
+ {iterable}
3376
+ </SuspenseList>
3377
+ );
3378
}
3379
3380
await act(() => {
3460
it('warns if a nested async iterable is passed to a "forwards" list', async () => {
3461
function Foo({items}) {
3462
return (
3273
- <SuspenseList revealOrder="forwards">
3463
+ <SuspenseList revealOrder="forwards" tail="visible">
3464
{items}
3465
<div>Tail</div>
3466
</SuspenseList>