Skip to content

Commit

Permalink
Replaced Error constructor with invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Feb 14, 2020
1 parent 1be4d26 commit 9968cf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ function useMutableSourceImpl<Source, Snapshot>(

invariant(
root !== null,
'Expected a work-in-progress root. This is likely a bug in React. Please file an issue.',
'Expected a work-in-progress root. This is a bug in React. Please file an issue.',
);

const pendingExpirationTime = getPendingExpirationTime(root, source);
Expand Down Expand Up @@ -932,9 +932,9 @@ function useMutableSourceImpl<Source, Snapshot>(
// This error won't be user-visible unless we throw again during re-render,
// but we should not do this since the retry-render will be synchronous.
// It would be a React error if this message was ever user visible.
throw Error(
'Cannot read from mutable source during the current render without tearing. ' +
'This is a bug in React. Please file an issue.',
invariant(
false,
'Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.',
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,6 @@
"345": "Root did not complete. This is a bug in React.",
"346": "An event responder context was used outside of an event cycle.",
"347": "Maps are not valid as a React child (found: %s). Consider converting children to an array of keyed ReactElements instead.",
"348": "Expected a work-in-progress root. This is likely a bug in React. Please file an issue."
"348": "Expected a work-in-progress root. This is a bug in React. Please file an issue.",
"349": "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
}

0 comments on commit 9968cf1

Please sign in to comment.