Skip to content

Commit

Permalink
Add warning to protect against refactor hazard
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite committed Mar 11, 2020
1 parent 1a55692 commit 62de1b3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/react-reconciler/src/ReactFiberHooks.js
Expand Up @@ -683,6 +683,16 @@ function updateReducer<S, I, A>(
baseQueue.next = pendingFirst;
pendingQueue.next = baseFirst;
}
if (__DEV__) {
if (current.baseQueue !== baseQueue) {
// Internal invariant that should never happen, but feasibly could in
// the future if we implement resuming, or some form of that.
console.error(
'Internal error: Expected work-in-progress queue to be a clone. ' +
'This is a bug in React.',
);
}
}
current.baseQueue = baseQueue = pendingQueue;
queue.pending = null;
}
Expand Down

0 comments on commit 62de1b3

Please sign in to comment.