Move SuspenseListProps into a shared/ReactTypes (#33298)
So they can be shared by server. Incorporates the types from definitely typed too.
Sebastian Markbåge committed
May 17, 2025 at 20:00 UTC
462d08f9ba41d48ab36bf405235c1c22023603dc
3 files changed
+29
-7
packages/react-reconciler/src/ReactFiberBeginWork.js
+4
-4
@@ -14,6 +14,9 @@ import type {
14
ViewTransitionProps,
15
ActivityProps,
16
SuspenseProps,
17
+ SuspenseListProps,
18
+ SuspenseListRevealOrder,
19
+ SuspenseListTailMode,
20
TracingMarkerProps,
21
CacheProps,
22
ProfilerProps,
@@ -26,7 +29,6 @@ import type {ActivityState} from './ReactFiberActivityComponent';
29
import type {
30
SuspenseState,
31
SuspenseListRenderState,
29
- SuspenseListTailMode,
32
} from './ReactFiberSuspenseComponent';
33
import type {SuspenseContext} from './ReactFiberSuspenseContext';
34
import type {
@@ -3222,8 +3224,6 @@ function findLastContentRow(firstChild: null | Fiber): null | Fiber {
3224
return lastContentRow;
3225
}
3226
3225
-type SuspenseListRevealOrder = 'forwards' | 'backwards' | 'together' | void;
3226
-
3227
function validateRevealOrder(revealOrder: SuspenseListRevealOrder) {
3228
if (__DEV__) {
3229
if (
@@ -3410,7 +3410,7 @@ function updateSuspenseListComponent(
3410
workInProgress: Fiber,
3411
renderLanes: Lanes,
3412
) {
3413
- const nextProps = workInProgress.pendingProps;
3413
+ const nextProps: SuspenseListProps = workInProgress.pendingProps;
3414
const revealOrder: SuspenseListRevealOrder = nextProps.revealOrder;
3415
const tailMode: SuspenseListTailMode = nextProps.tail;
3416
const newChildren = nextProps.children;
packages/react-reconciler/src/ReactFiberSuspenseComponent.js
+1
-3
@@ -7,7 +7,7 @@
7
* @flow
8
*/
9
10
-import type {Wakeable} from 'shared/ReactTypes';
10
+import type {Wakeable, SuspenseListTailMode} from 'shared/ReactTypes';
11
import type {Fiber} from './ReactInternalTypes';
12
import type {SuspenseInstance} from './ReactFiberConfig';
13
import type {Lane} from './ReactFiberLane';
@@ -42,8 +42,6 @@ export type SuspenseState = {
42
hydrationErrors: Array<CapturedValue<mixed>> | null,
43
};
44
45
-export type SuspenseListTailMode = 'collapsed' | 'hidden' | void;
46
-
45
export type SuspenseListRenderState = {
46
isBackwards: boolean,
47
// The currently rendering tail row.
packages/shared/ReactTypes.js
+24
@@ -290,6 +290,30 @@ export type SuspenseProps = {
290
name?: string,
291
};
292
293
+export type SuspenseListRevealOrder =
294
+ | 'forwards'
295
+ | 'backwards'
296
+ | 'together'
297
+ | void;
298
+
299
+export type SuspenseListTailMode = 'collapsed' | 'hidden' | void;
300
+
301
+type DirectionalSuspenseListProps = {
302
+ children?: ReactNodeList,
303
+ revealOrder: 'forwards' | 'backwards',
304
+ tail?: SuspenseListTailMode,
305
+};
306
+
307
+type NonDirectionalSuspenseListProps = {
308
+ children?: ReactNodeList,
309
+ revealOrder?: 'together' | void,
310
+ tail?: void,
311
+};
312
+
313
+export type SuspenseListProps =
314
+ | DirectionalSuspenseListProps
315
+ | NonDirectionalSuspenseListProps;
316
+
317
export type TracingMarkerProps = {
318
name: string,
319
children?: ReactNodeList,