1294
request: Request,
1295
task: Task,
1296
keyPath: KeyNode,
1297
- prevThenableState: ThenableState | null,
1297
Component: (p: Props, arg: SecondArg) => any,
1298
props: Props,
1299
secondArg: SecondArg,
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;
1306
const componentIdentity = {};
1307
prepareToUseHooks(
1308
request,
1349
childContextTypes,
1350
);
1351
task.legacyContext = mergedContext;
1348
- renderNodeDestructive(request, task, null, nextChildren, -1);
1352
+ renderNodeDestructive(request, task, nextChildren, -1);
1353
task.legacyContext = previousContext;
1354
return;
1355
}
1357
1358
const prevKeyPath = task.keyPath;
1359
task.keyPath = keyPath;
1356
- renderNodeDestructive(request, task, null, nextChildren, -1);
1360
+ renderNodeDestructive(request, task, nextChildren, -1);
1361
task.keyPath = prevKeyPath;
1362
}
1363
1395
request: Request,
1396
task: Task,
1397
keyPath: KeyNode,
1394
- prevThenableState: ThenableState | null,
1398
Component: any,
1399
props: any,
1400
): void {
1428
request,
1429
task,
1430
keyPath,
1428
- prevThenableState,
1431
Component,
1432
props,
1433
legacyContext,
1571
// We're now successfully past this task, and we haven't modified the
1572
// context stack. We don't have to pop back to the previous task every
1573
// again, so we can use the destructive recursive form.
1572
- renderNodeDestructive(request, task, null, children, -1);
1574
+ renderNodeDestructive(request, task, children, -1);
1575
}
1576
task.keyPath = prevKeyPath;
1577
}
1648
request: Request,
1649
task: Task,
1650
keyPath: KeyNode,
1649
- prevThenableState: null | ThenableState,
1651
type: any,
1652
props: Object,
1653
ref: any,
1658
request,
1659
task,
1660
keyPath,
1660
- prevThenableState,
1661
type.render,
1662
props,
1663
ref,
1681
request: Request,
1682
task: Task,
1683
keyPath: KeyNode,
1684
- prevThenableState: ThenableState | null,
1684
type: any,
1685
props: Object,
1686
ref: any,
1687
): void {
1688
const innerType = type.type;
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);
1691
}
1692
1693
function renderContextConsumer(
1740
1741
const prevKeyPath = task.keyPath;
1742
task.keyPath = keyPath;
1752
- renderNodeDestructive(request, task, null, newChildren, -1);
1743
+ renderNodeDestructive(request, task, newChildren, -1);
1744
task.keyPath = prevKeyPath;
1745
}
1746
1761
const prevKeyPath = task.keyPath;
1762
task.context = pushProvider(context, value);
1763
task.keyPath = keyPath;
1773
- renderNodeDestructive(request, task, null, children, -1);
1764
+ renderNodeDestructive(request, task, children, -1);
1765
task.context = popProvider(context);
1766
task.keyPath = prevKeyPath;
1767
if (__DEV__) {
1777
request: Request,
1778
task: Task,
1779
keyPath: KeyNode,
1789
- prevThenableState: ThenableState | null,
1780
lazyComponent: LazyComponentType<any, any>,
1781
props: Object,
1782
ref: any,
1787
const init = lazyComponent._init;
1788
const Component = init(payload);
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);
1791
task.componentStack = previousComponentStack;
1792
}
1793
1806
// pure indirection.
1807
const prevKeyPath = task.keyPath;
1808
task.keyPath = keyPath;
1827
- renderNodeDestructive(request, task, null, props.children, -1);
1809
+ renderNodeDestructive(request, task, props.children, -1);
1810
task.keyPath = prevKeyPath;
1811
}
1812
}
1815
request: Request,
1816
task: Task,
1817
keyPath: KeyNode,
1836
- prevThenableState: ThenableState | null,
1818
type: any,
1819
props: Object,
1820
ref: any,
1824
renderClassComponent(request, task, keyPath, type, props);
1825
return;
1826
} else {
1846
- renderIndeterminateComponent(
1847
- request,
1848
- task,
1849
- keyPath,
1850
- prevThenableState,
1851
- type,
1852
- props,
1853
- );
1827
+ renderIndeterminateComponent(request, task, keyPath, type, props);
1828
return;
1829
}
1830
}
1850
case REACT_FRAGMENT_TYPE: {
1851
const prevKeyPath = task.keyPath;
1852
task.keyPath = keyPath;
1879
- renderNodeDestructive(request, task, null, props.children, -1);
1853
+ renderNodeDestructive(request, task, props.children, -1);
1854
task.keyPath = prevKeyPath;
1855
return;
1856
}
1864
// TODO: SuspenseList should control the boundaries.
1865
const prevKeyPath = task.keyPath;
1866
task.keyPath = keyPath;
1893
- renderNodeDestructive(request, task, null, props.children, -1);
1867
+ renderNodeDestructive(request, task, props.children, -1);
1868
task.keyPath = prevKeyPath;
1869
task.componentStack = preiousComponentStack;
1870
return;
1873
if (enableScopeAPI) {
1874
const prevKeyPath = task.keyPath;
1875
task.keyPath = keyPath;
1902
- renderNodeDestructive(request, task, null, props.children, -1);
1876
+ renderNodeDestructive(request, task, props.children, -1);
1877
task.keyPath = prevKeyPath;
1878
return;
1879
}
1895
if (typeof type === 'object' && type !== null) {
1896
switch (type.$$typeof) {
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);
1899
return;
1900
}
1901
case REACT_MEMO_TYPE: {
1936
- renderMemo(request, task, keyPath, prevThenableState, type, props, ref);
1902
+ renderMemo(request, task, keyPath, type, props, ref);
1903
return;
1904
}
1905
case REACT_PROVIDER_TYPE: {
1911
return;
1912
}
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);
1915
return;
1916
}
1917
}
1984
request: Request,
1985
task: ReplayTask,
1986
keyPath: KeyNode,
2028
- prevThenableState: ThenableState | null,
1987
name: null | string,
1988
keyOrIndex: number | string,
1989
childIndex: number,
2018
const currentNode = task.node;
2019
task.replay = {nodes: childNodes, slots: childSlots, pendingTasks: 1};
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);
2022
if (
2023
task.replay.pendingTasks === 1 &&
2024
task.replay.nodes.length > 0
2134
function renderNodeDestructive(
2135
request: Request,
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,
2137
node: ReactNodeList,
2138
childIndex: number,
2139
): void {
2170
request,
2171
task,
2172
keyPath,
2226
- prevThenableState,
2173
name,
2174
keyOrIndex,
2175
childIndex,
2182
// prelude and skip it during the replay.
2183
} else {
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);
2186
}
2187
return;
2188
}
2204
task.componentStack = previousComponentStack;
2205
2206
// Now we render the resolved node
2269
- renderNodeDestructive(request, task, null, resolvedNode, childIndex);
2207
+ renderNodeDestructive(request, task, resolvedNode, childIndex);
2208
return;
2209
}
2210
}
2252
// e.g. Usable<Usable<Usable<T>>> should resolve to T
2253
const maybeUsable: Object = node;
2254
if (typeof maybeUsable.then === 'function') {
2255
+ // Clear any previous thenable state that was created by the unwrapping.
2256
+ task.thenableState = null;
2257
const thenable: Thenable<ReactNodeList> = (maybeUsable: any);
2258
return renderNodeDestructive(
2259
request,
2260
task,
2321
- null,
2261
unwrapThenable(thenable),
2262
childIndex,
2263
);
2271
return renderNodeDestructive(
2272
request,
2273
task,
2335
- null,
2274
readContext(context),
2275
childIndex,
2276
);
2765
if (segment === null) {
2766
// Replay
2767
try {
2830
- return renderNodeDestructive(request, task, null, node, childIndex);
2768
+ return renderNodeDestructive(request, task, node, childIndex);
2769
} catch (thrownValue) {
2770
resetHooksState();
2771
2813
const childrenLength = segment.children.length;
2814
const chunkLength = segment.chunks.length;
2815
try {
2878
- return renderNodeDestructive(request, task, null, node, childIndex);
2816
+ return renderNodeDestructive(request, task, node, childIndex);
2817
} catch (thrownValue) {
2818
resetHooksState();
2819
3394
// We call the destructive form that mutates this task. That way if something
3395
// suspends again, we can reuse the same task instead of spawning a new one.
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);
3398
pushSegmentFinale(
3399
segment.chunks,
3400
request.renderState,
3485
// We call the destructive form that mutates this task. That way if something
3486
// suspends again, we can reuse the same task instead of spawning a new one.
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);
3489
3490
if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) {
3491
throw new Error(