Skip to content

Commit 62de1b3

Browse files
committed
Add warning to protect against refactor hazard
The hook queue does not have resuming or "captured" updates, but if we ever add them in the future, we'll need to make sure we check if the queue is forked before transfering the pending updates to them.
1 parent 1a55692 commit 62de1b3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,16 @@ function updateReducer<S, I, A>(
683683
baseQueue.next = pendingFirst;
684684
pendingQueue.next = baseFirst;
685685
}
686+
if (__DEV__) {
687+
if (current.baseQueue !== baseQueue) {
688+
// Internal invariant that should never happen, but feasibly could in
689+
// the future if we implement resuming, or some form of that.
690+
console.error(
691+
'Internal error: Expected work-in-progress queue to be a clone. ' +
692+
'This is a bug in React.',
693+
);
694+
}
695+
}
686696
current.baseQueue = baseQueue = pendingQueue;
687697
queue.pending = null;
688698
}

0 commit comments

Comments
 (0)