770
ignorePreviousDependencies =
771
current !== null && current.type !== workInProgress.type;
772
}
773
+ // renderWithHooks only resets the updateQueue but does not clear it, since
774
+ // it needs to work for both this case (suspense replay) as well as for double
775
+ // renders in dev and setState-in-render. However, for the suspense replay case
776
+ // we need to reset the updateQueue to correctly handle unmount effects, so we
777
+ // clear the queue here
778
+ workInProgress.updateQueue = null;
779
const children = renderWithHooksAgain(
780
workInProgress,
781
Component,
834
currentHook = null;
835
workInProgressHook = null;
836
831
- workInProgress.updateQueue = null;
837
+ if (workInProgress.updateQueue != null) {
838
+ resetFunctionComponentUpdateQueue((workInProgress.updateQueue: any));
839
+ }
840
841
if (__DEV__) {
842
// Also validate hook order for cascading updates.
1109
};
1110
}
1111
1112
+function resetFunctionComponentUpdateQueue(
1113
+ updateQueue: FunctionComponentUpdateQueue,
1114
+): void {
1115
+ updateQueue.lastEffect = null;
1116
+ updateQueue.events = null;
1117
+ updateQueue.stores = null;
1118
+ if (enableUseMemoCacheHook) {
1119
+ if (updateQueue.memoCache != null) {
1120
+ // NOTE: this function intentionally does not reset memoCache data. We reuse updateQueue for the memo
1121
+ // cache to avoid increasing the size of fibers that don't need a cache, but we don't want to reset
1122
+ // the cache when other properties are reset.
1123
+ updateQueue.memoCache.index = 0;
1124
+ }
1125
+ }
1126
+}
1127
+
1128
function useThenable<T>(thenable: Thenable<T>): T {
1129
// Track the position of the thenable within this fiber.
1130
const index = thenableIndexCounter;
2520
if (componentUpdateQueue === null) {
2521
componentUpdateQueue = createFunctionComponentUpdateQueue();
2522
currentlyRenderingFiber.updateQueue = (componentUpdateQueue: any);
2523
+ }
2524
+ const lastEffect = componentUpdateQueue.lastEffect;
2525
+ if (lastEffect === null) {
2526
componentUpdateQueue.lastEffect = effect.next = effect;
2527
} else {
2501
- const lastEffect = componentUpdateQueue.lastEffect;
2502
- if (lastEffect === null) {
2503
- componentUpdateQueue.lastEffect = effect.next = effect;
2504
- } else {
2505
- const firstEffect = lastEffect.next;
2506
- lastEffect.next = effect;
2507
- effect.next = firstEffect;
2508
- componentUpdateQueue.lastEffect = effect;
2509
- }
2528
+ const firstEffect = lastEffect.next;
2529
+ lastEffect.next = effect;
2530
+ effect.next = firstEffect;
2531
+ componentUpdateQueue.lastEffect = effect;
2532
}
2533
return effect;
2534
}