@@ -990,16 +990,6 @@ function updateSuspenseComponent(
990
990
}
991
991
}
992
992
993
- // If the `children` prop is a function, treat it like a render prop.
994
- // TODO: Remove this, or put it behind a feature flag
995
- const children = nextProps . children ;
996
- let nextChildren ;
997
- if ( typeof children === 'function' ) {
998
- nextChildren = children ( nextDidTimeout ) ;
999
- } else {
1000
- nextChildren = nextDidTimeout ? nextProps . fallback : children ;
1001
- }
1002
-
1003
993
// This next part is a bit confusing. If the children timeout, we switch to
1004
994
// showing the fallback children in place of the "primary" children.
1005
995
// However, we don't want to delete the primary children because then their
@@ -1036,14 +1026,15 @@ function updateSuspenseComponent(
1036
1026
// no previous state that needs to be preserved.
1037
1027
if ( nextDidTimeout ) {
1038
1028
// Mount separate fragments for primary and fallback children.
1029
+ const nextFallbackChildren = nextProps . fallback ;
1039
1030
const primaryChildFragment = createFiberFromFragment (
1040
1031
null ,
1041
1032
mode ,
1042
1033
NoWork ,
1043
1034
null ,
1044
1035
) ;
1045
1036
const fallbackChildFragment = createFiberFromFragment (
1046
- nextChildren ,
1037
+ nextFallbackChildren ,
1047
1038
mode ,
1048
1039
renderExpirationTime ,
1049
1040
null ,
@@ -1056,10 +1047,11 @@ function updateSuspenseComponent(
1056
1047
child . return = next . return = workInProgress ;
1057
1048
} else {
1058
1049
// Mount the primary children without an intermediate fragment fiber.
1050
+ const nextPrimaryChildren = nextProps . children ;
1059
1051
child = next = mountChildFibers (
1060
1052
workInProgress ,
1061
1053
null ,
1062
- nextChildren ,
1054
+ nextPrimaryChildren ,
1063
1055
renderExpirationTime ,
1064
1056
) ;
1065
1057
}
@@ -1076,6 +1068,7 @@ function updateSuspenseComponent(
1076
1068
if ( nextDidTimeout ) {
1077
1069
// Still timed out. Reuse the current primary children by cloning
1078
1070
// its fragment. We're going to skip over these entirely.
1071
+ const nextFallbackChildren = nextProps . fallback ;
1079
1072
const primaryChildFragment = createWorkInProgress (
1080
1073
currentFallbackChildFragment ,
1081
1074
currentFallbackChildFragment . pendingProps ,
@@ -1086,7 +1079,7 @@ function updateSuspenseComponent(
1086
1079
// working on.
1087
1080
const fallbackChildFragment = ( primaryChildFragment . sibling = createWorkInProgress (
1088
1081
currentFallbackChildFragment ,
1089
- nextChildren ,
1082
+ nextFallbackChildren ,
1090
1083
currentFallbackChildFragment . expirationTime ,
1091
1084
) ) ;
1092
1085
fallbackChildFragment . effectTag |= Placement ;
@@ -1098,12 +1091,13 @@ function updateSuspenseComponent(
1098
1091
} else {
1099
1092
// No longer suspended. Switch back to showing the primary children,
1100
1093
// and remove the intermediate fragment fiber.
1094
+ const nextPrimaryChildren = nextProps . children ;
1101
1095
const currentPrimaryChild = currentPrimaryChildFragment . child ;
1102
1096
const currentFallbackChild = currentFallbackChildFragment . child ;
1103
1097
const primaryChild = reconcileChildFibers (
1104
1098
workInProgress ,
1105
1099
currentPrimaryChild ,
1106
- nextChildren ,
1100
+ nextPrimaryChildren ,
1107
1101
renderExpirationTime ,
1108
1102
) ;
1109
1103
// Delete the fallback children.
@@ -1123,6 +1117,7 @@ function updateSuspenseComponent(
1123
1117
if ( nextDidTimeout ) {
1124
1118
// Timed out. Wrap the children in a fragment fiber to keep them
1125
1119
// separate from the fallback children.
1120
+ const nextFallbackChildren = nextProps . fallback ;
1126
1121
const primaryChildFragment = createFiberFromFragment (
1127
1122
// It shouldn't matter what the pending props are because we aren't
1128
1123
// going to render this fragment.
@@ -1136,7 +1131,7 @@ function updateSuspenseComponent(
1136
1131
currentPrimaryChild . return = primaryChildFragment ;
1137
1132
// Create a fragment from the fallback children, too.
1138
1133
const fallbackChildFragment = ( primaryChildFragment . sibling = createFiberFromFragment (
1139
- nextChildren ,
1134
+ nextFallbackChildren ,
1140
1135
mode ,
1141
1136
renderExpirationTime ,
1142
1137
null ,
@@ -1150,10 +1145,11 @@ function updateSuspenseComponent(
1150
1145
} else {
1151
1146
// Still haven't timed out. Continue rendering the children, like we
1152
1147
// normally do.
1148
+ const nextPrimaryChildren = nextProps . children ;
1153
1149
next = child = reconcileChildFibers (
1154
1150
workInProgress ,
1155
1151
currentPrimaryChild ,
1156
- nextChildren ,
1152
+ nextPrimaryChildren ,
1157
1153
renderExpirationTime ,
1158
1154
) ;
1159
1155
}
0 commit comments