@@ -1294,11 +1294,15 @@ function renderWithHooks<Props, SecondArg>(
1294
1294
request : Request ,
1295
1295
task : Task ,
1296
1296
keyPath : KeyNode ,
1297
- prevThenableState : ThenableState | null ,
1298
1297
Component : ( p : Props , arg : SecondArg ) => any ,
1299
1298
props : Props ,
1300
1299
secondArg : SecondArg ,
1301
1300
) : any {
1301
+ // Reset the task's thenable state before continuing, so that if a later
1302
+ // component suspends we can reuse the same task object. If the same
1303
+ // component suspends again, the thenable state will be restored.
1304
+ const prevThenableState = task . thenableState ;
1305
+ task . thenableState = null ;
1302
1306
const componentIdentity = { } ;
1303
1307
prepareToUseHooks (
1304
1308
request ,
@@ -1345,15 +1349,15 @@ function finishClassComponent(
1345
1349
childContextTypes ,
1346
1350
) ;
1347
1351
task . legacyContext = mergedContext ;
1348
- renderNodeDestructive ( request , task , null , nextChildren , - 1 ) ;
1352
+ renderNodeDestructive ( request , task , nextChildren , - 1 ) ;
1349
1353
task . legacyContext = previousContext ;
1350
1354
return ;
1351
1355
}
1352
1356
}
1353
1357
1354
1358
const prevKeyPath = task . keyPath ;
1355
1359
task . keyPath = keyPath ;
1356
- renderNodeDestructive ( request , task , null , nextChildren , - 1 ) ;
1360
+ renderNodeDestructive ( request , task , nextChildren , - 1 ) ;
1357
1361
task . keyPath = prevKeyPath ;
1358
1362
}
1359
1363
@@ -1391,7 +1395,6 @@ function renderIndeterminateComponent(
1391
1395
request : Request ,
1392
1396
task : Task ,
1393
1397
keyPath : KeyNode ,
1394
- prevThenableState : ThenableState | null ,
1395
1398
Component : any ,
1396
1399
props : any ,
1397
1400
) : void {
@@ -1425,7 +1428,6 @@ function renderIndeterminateComponent(
1425
1428
request ,
1426
1429
task ,
1427
1430
keyPath ,
1428
- prevThenableState ,
1429
1431
Component ,
1430
1432
props ,
1431
1433
legacyContext ,
@@ -1569,7 +1571,7 @@ function finishFunctionComponent(
1569
1571
// We're now successfully past this task, and we haven't modified the
1570
1572
// context stack. We don't have to pop back to the previous task every
1571
1573
// again, so we can use the destructive recursive form.
1572
- renderNodeDestructive ( request , task , null , children , - 1 ) ;
1574
+ renderNodeDestructive ( request , task , children , - 1 ) ;
1573
1575
}
1574
1576
task . keyPath = prevKeyPath ;
1575
1577
}
@@ -1646,7 +1648,6 @@ function renderForwardRef(
1646
1648
request : Request ,
1647
1649
task : Task ,
1648
1650
keyPath : KeyNode ,
1649
- prevThenableState : null | ThenableState ,
1650
1651
type : any ,
1651
1652
props : Object ,
1652
1653
ref : any ,
@@ -1657,7 +1658,6 @@ function renderForwardRef(
1657
1658
request ,
1658
1659
task ,
1659
1660
keyPath ,
1660
- prevThenableState ,
1661
1661
type . render ,
1662
1662
props ,
1663
1663
ref ,
@@ -1681,22 +1681,13 @@ function renderMemo(
1681
1681
request : Request ,
1682
1682
task : Task ,
1683
1683
keyPath : KeyNode ,
1684
- prevThenableState : ThenableState | null ,
1685
1684
type : any ,
1686
1685
props : Object ,
1687
1686
ref : any ,
1688
1687
) : void {
1689
1688
const innerType = type . type ;
1690
1689
const resolvedProps = resolveDefaultProps ( innerType , props ) ;
1691
- renderElement (
1692
- request ,
1693
- task ,
1694
- keyPath ,
1695
- prevThenableState ,
1696
- innerType ,
1697
- resolvedProps ,
1698
- ref ,
1699
- ) ;
1690
+ renderElement ( request , task , keyPath , innerType , resolvedProps , ref ) ;
1700
1691
}
1701
1692
1702
1693
function renderContextConsumer (
@@ -1749,7 +1740,7 @@ function renderContextConsumer(
1749
1740
1750
1741
const prevKeyPath = task . keyPath ;
1751
1742
task . keyPath = keyPath ;
1752
- renderNodeDestructive ( request , task , null , newChildren , - 1 ) ;
1743
+ renderNodeDestructive ( request , task , newChildren , - 1 ) ;
1753
1744
task . keyPath = prevKeyPath ;
1754
1745
}
1755
1746
@@ -1770,7 +1761,7 @@ function renderContextProvider(
1770
1761
const prevKeyPath = task . keyPath ;
1771
1762
task . context = pushProvider ( context , value ) ;
1772
1763
task . keyPath = keyPath ;
1773
- renderNodeDestructive ( request , task , null , children , - 1 ) ;
1764
+ renderNodeDestructive ( request , task , children , - 1 ) ;
1774
1765
task . context = popProvider ( context ) ;
1775
1766
task . keyPath = prevKeyPath ;
1776
1767
if ( __DEV__ ) {
@@ -1786,7 +1777,6 @@ function renderLazyComponent(
1786
1777
request : Request ,
1787
1778
task : Task ,
1788
1779
keyPath : KeyNode ,
1789
- prevThenableState : ThenableState | null ,
1790
1780
lazyComponent : LazyComponentType < any , any > ,
1791
1781
props : Object ,
1792
1782
ref : any ,
@@ -1797,15 +1787,7 @@ function renderLazyComponent(
1797
1787
const init = lazyComponent . _init ;
1798
1788
const Component = init ( payload ) ;
1799
1789
const resolvedProps = resolveDefaultProps ( Component , props ) ;
1800
- renderElement (
1801
- request ,
1802
- task ,
1803
- keyPath ,
1804
- prevThenableState ,
1805
- Component ,
1806
- resolvedProps ,
1807
- ref ,
1808
- ) ;
1790
+ renderElement ( request , task , keyPath , Component , resolvedProps , ref ) ;
1809
1791
task . componentStack = previousComponentStack ;
1810
1792
}
1811
1793
@@ -1824,7 +1806,7 @@ function renderOffscreen(
1824
1806
// pure indirection.
1825
1807
const prevKeyPath = task . keyPath ;
1826
1808
task . keyPath = keyPath ;
1827
- renderNodeDestructive ( request , task , null , props . children , - 1 ) ;
1809
+ renderNodeDestructive ( request , task , props . children , - 1 ) ;
1828
1810
task . keyPath = prevKeyPath ;
1829
1811
}
1830
1812
}
@@ -1833,7 +1815,6 @@ function renderElement(
1833
1815
request : Request ,
1834
1816
task : Task ,
1835
1817
keyPath : KeyNode ,
1836
- prevThenableState : ThenableState | null ,
1837
1818
type : any ,
1838
1819
props : Object ,
1839
1820
ref : any ,
@@ -1843,14 +1824,7 @@ function renderElement(
1843
1824
renderClassComponent ( request , task , keyPath , type , props ) ;
1844
1825
return ;
1845
1826
} else {
1846
- renderIndeterminateComponent (
1847
- request ,
1848
- task ,
1849
- keyPath ,
1850
- prevThenableState ,
1851
- type ,
1852
- props ,
1853
- ) ;
1827
+ renderIndeterminateComponent ( request , task , keyPath , type , props ) ;
1854
1828
return ;
1855
1829
}
1856
1830
}
@@ -1876,7 +1850,7 @@ function renderElement(
1876
1850
case REACT_FRAGMENT_TYPE : {
1877
1851
const prevKeyPath = task . keyPath ;
1878
1852
task . keyPath = keyPath ;
1879
- renderNodeDestructive ( request , task , null , props . children , - 1 ) ;
1853
+ renderNodeDestructive ( request , task , props . children , - 1 ) ;
1880
1854
task . keyPath = prevKeyPath ;
1881
1855
return ;
1882
1856
}
@@ -1890,7 +1864,7 @@ function renderElement(
1890
1864
// TODO: SuspenseList should control the boundaries.
1891
1865
const prevKeyPath = task . keyPath ;
1892
1866
task . keyPath = keyPath ;
1893
- renderNodeDestructive ( request , task , null , props . children , - 1 ) ;
1867
+ renderNodeDestructive ( request , task , props . children , - 1 ) ;
1894
1868
task . keyPath = prevKeyPath ;
1895
1869
task . componentStack = preiousComponentStack ;
1896
1870
return ;
@@ -1899,7 +1873,7 @@ function renderElement(
1899
1873
if ( enableScopeAPI ) {
1900
1874
const prevKeyPath = task . keyPath ;
1901
1875
task . keyPath = keyPath ;
1902
- renderNodeDestructive ( request , task , null , props . children , - 1 ) ;
1876
+ renderNodeDestructive ( request , task , props . children , - 1 ) ;
1903
1877
task . keyPath = prevKeyPath ;
1904
1878
return ;
1905
1879
}
@@ -1921,19 +1895,11 @@ function renderElement(
1921
1895
if ( typeof type === 'object' && type !== null ) {
1922
1896
switch ( type . $$typeof ) {
1923
1897
case REACT_FORWARD_REF_TYPE : {
1924
- renderForwardRef (
1925
- request ,
1926
- task ,
1927
- keyPath ,
1928
- prevThenableState ,
1929
- type ,
1930
- props ,
1931
- ref ,
1932
- ) ;
1898
+ renderForwardRef ( request , task , keyPath , type , props , ref ) ;
1933
1899
return ;
1934
1900
}
1935
1901
case REACT_MEMO_TYPE : {
1936
- renderMemo ( request , task , keyPath , prevThenableState , type , props , ref ) ;
1902
+ renderMemo ( request , task , keyPath , type , props , ref ) ;
1937
1903
return ;
1938
1904
}
1939
1905
case REACT_PROVIDER_TYPE : {
@@ -1945,14 +1911,7 @@ function renderElement(
1945
1911
return ;
1946
1912
}
1947
1913
case REACT_LAZY_TYPE : {
1948
- renderLazyComponent (
1949
- request ,
1950
- task ,
1951
- keyPath ,
1952
- prevThenableState ,
1953
- type ,
1954
- props ,
1955
- ) ;
1914
+ renderLazyComponent ( request , task , keyPath , type , props ) ;
1956
1915
return ;
1957
1916
}
1958
1917
}
@@ -2025,7 +1984,6 @@ function replayElement(
2025
1984
request : Request ,
2026
1985
task : ReplayTask ,
2027
1986
keyPath : KeyNode ,
2028
- prevThenableState : ThenableState | null ,
2029
1987
name : null | string ,
2030
1988
keyOrIndex : number | string ,
2031
1989
childIndex : number ,
@@ -2060,15 +2018,7 @@ function replayElement(
2060
2018
const currentNode = task . node ;
2061
2019
task . replay = { nodes : childNodes , slots : childSlots , pendingTasks : 1 } ;
2062
2020
try {
2063
- renderElement (
2064
- request ,
2065
- task ,
2066
- keyPath ,
2067
- prevThenableState ,
2068
- type ,
2069
- props ,
2070
- ref ,
2071
- ) ;
2021
+ renderElement ( request , task , keyPath , type , props , ref ) ;
2072
2022
if (
2073
2023
task . replay . pendingTasks === 1 &&
2074
2024
task . replay . nodes . length > 0
@@ -2184,9 +2134,6 @@ function validateIterable(iterable, iteratorFn: Function): void {
2184
2134
function renderNodeDestructive (
2185
2135
request : Request ,
2186
2136
task : Task ,
2187
- // The thenable state reused from the previous attempt, if any. This is almost
2188
- // always null, except when called by retryTask.
2189
- prevThenableState : ThenableState | null ,
2190
2137
node : ReactNodeList ,
2191
2138
childIndex : number ,
2192
2139
) : void {
@@ -2223,7 +2170,6 @@ function renderNodeDestructive(
2223
2170
request ,
2224
2171
task ,
2225
2172
keyPath ,
2226
- prevThenableState ,
2227
2173
name ,
2228
2174
keyOrIndex ,
2229
2175
childIndex ,
@@ -2236,15 +2182,7 @@ function renderNodeDestructive(
2236
2182
// prelude and skip it during the replay.
2237
2183
} else {
2238
2184
// We're doing a plain render.
2239
- renderElement (
2240
- request ,
2241
- task ,
2242
- keyPath ,
2243
- prevThenableState ,
2244
- type ,
2245
- props ,
2246
- ref ,
2247
- ) ;
2185
+ renderElement ( request , task , keyPath , type , props , ref ) ;
2248
2186
}
2249
2187
return ;
2250
2188
}
@@ -2266,7 +2204,7 @@ function renderNodeDestructive(
2266
2204
task . componentStack = previousComponentStack ;
2267
2205
2268
2206
// Now we render the resolved node
2269
- renderNodeDestructive ( request , task , null , resolvedNode , childIndex ) ;
2207
+ renderNodeDestructive ( request , task , resolvedNode , childIndex ) ;
2270
2208
return ;
2271
2209
}
2272
2210
}
@@ -2314,11 +2252,12 @@ function renderNodeDestructive(
2314
2252
// e.g. Usable<Usable<Usable<T>>> should resolve to T
2315
2253
const maybeUsable : Object = node ;
2316
2254
if ( typeof maybeUsable . then === 'function' ) {
2255
+ // Clear any previous thenable state that was created by the unwrapping.
2256
+ task . thenableState = null ;
2317
2257
const thenable : Thenable < ReactNodeList > = ( maybeUsable : any ) ;
2318
2258
return renderNodeDestructive (
2319
2259
request ,
2320
2260
task ,
2321
- null ,
2322
2261
unwrapThenable ( thenable ) ,
2323
2262
childIndex ,
2324
2263
) ;
@@ -2332,7 +2271,6 @@ function renderNodeDestructive(
2332
2271
return renderNodeDestructive (
2333
2272
request ,
2334
2273
task ,
2335
- null ,
2336
2274
readContext ( context ) ,
2337
2275
childIndex ,
2338
2276
) ;
@@ -2827,7 +2765,7 @@ function renderNode(
2827
2765
if ( segment === null ) {
2828
2766
// Replay
2829
2767
try {
2830
- return renderNodeDestructive ( request , task , null , node , childIndex ) ;
2768
+ return renderNodeDestructive ( request , task , node , childIndex ) ;
2831
2769
} catch ( thrownValue ) {
2832
2770
resetHooksState ( ) ;
2833
2771
@@ -2875,7 +2813,7 @@ function renderNode(
2875
2813
const childrenLength = segment . children . length ;
2876
2814
const chunkLength = segment . chunks . length ;
2877
2815
try {
2878
- return renderNodeDestructive ( request , task , null , node , childIndex ) ;
2816
+ return renderNodeDestructive ( request , task , node , childIndex ) ;
2879
2817
} catch ( thrownValue ) {
2880
2818
resetHooksState ( ) ;
2881
2819
@@ -3456,19 +3394,7 @@ function retryRenderTask(
3456
3394
// We call the destructive form that mutates this task. That way if something
3457
3395
// suspends again, we can reuse the same task instead of spawning a new one.
3458
3396
3459
- // Reset the task's thenable state before continuing, so that if a later
3460
- // component suspends we can reuse the same task object. If the same
3461
- // component suspends again, the thenable state will be restored.
3462
- const prevThenableState = task . thenableState ;
3463
- task . thenableState = null ;
3464
-
3465
- renderNodeDestructive (
3466
- request ,
3467
- task ,
3468
- prevThenableState ,
3469
- task . node ,
3470
- task . childIndex ,
3471
- ) ;
3397
+ renderNodeDestructive ( request , task , task . node , task . childIndex ) ;
3472
3398
pushSegmentFinale (
3473
3399
segment . chunks ,
3474
3400
request . renderState ,
@@ -3559,19 +3485,7 @@ function retryReplayTask(request: Request, task: ReplayTask): void {
3559
3485
// We call the destructive form that mutates this task. That way if something
3560
3486
// suspends again, we can reuse the same task instead of spawning a new one.
3561
3487
3562
- // Reset the task's thenable state before continuing, so that if a later
3563
- // component suspends we can reuse the same task object. If the same
3564
- // component suspends again, the thenable state will be restored.
3565
- const prevThenableState = task . thenableState ;
3566
- task . thenableState = null ;
3567
-
3568
- renderNodeDestructive (
3569
- request ,
3570
- task ,
3571
- prevThenableState ,
3572
- task . node ,
3573
- task . childIndex ,
3574
- ) ;
3488
+ renderNodeDestructive ( request , task , task . node , task . childIndex ) ;
3575
3489
3576
3490
if ( task . replay . pendingTasks === 1 && task . replay . nodes . length > 0 ) {
3577
3491
throw new Error (
0 commit comments