Skip to content

Commit

Permalink
Convert invariant to warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jan 27, 2021
1 parent 2c7a2eb commit 22f7355
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,15 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
if (__DEV__) {
// If we're going to re-use an existing task, it needs to exist.
// Assume that discrete update microtasks are non-cancellable and null.
invariant(
existingCallbackNode != null ||
newCallbackPriority === InputDiscreteLanePriority,
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
);
// TODO: Temporary until we confirm this warning is not fired.
if (
existingCallbackNode == null &&
newCallbackPriority !== InputDiscreteLanePriority
) {
console.error(
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
);
}
}
// The priority hasn't changed. We can reuse the existing task. Exit.
return;
Expand Down
14 changes: 9 additions & 5 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,15 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
if (__DEV__) {
// If we're going to re-use an existing task, it needs to exist.
// Assume that discrete update microtasks are non-cancellable and null.
invariant(
existingCallbackNode != null ||
newCallbackPriority === InputDiscreteLanePriority,
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
);
// TODO: Temporary until we confirm this warning is not fired.
if (
existingCallbackNode == null &&
newCallbackPriority !== InputDiscreteLanePriority
) {
console.error(
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
);
}
}
// The priority hasn't changed. We can reuse the existing task. Exit.
return;
Expand Down

0 comments on commit 22f7355

Please sign in to comment.