Skip to content

Commit 9968cf1

Browse files
author
Brian Vaughn
committed
Replaced Error constructor with invariant
1 parent 1be4d26 commit 9968cf1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ function useMutableSourceImpl<Source, Snapshot>(
871871

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

877877
const pendingExpirationTime = getPendingExpirationTime(root, source);
@@ -932,9 +932,9 @@ function useMutableSourceImpl<Source, Snapshot>(
932932
// This error won't be user-visible unless we throw again during re-render,
933933
// but we should not do this since the retry-render will be synchronous.
934934
// It would be a React error if this message was ever user visible.
935-
throw Error(
936-
'Cannot read from mutable source during the current render without tearing. ' +
937-
'This is a bug in React. Please file an issue.',
935+
invariant(
936+
false,
937+
'Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.',
938938
);
939939
}
940940
}

scripts/error-codes/codes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,5 +346,6 @@
346346
"345": "Root did not complete. This is a bug in React.",
347347
"346": "An event responder context was used outside of an event cycle.",
348348
"347": "Maps are not valid as a React child (found: %s). Consider converting children to an array of keyed ReactElements instead.",
349-
"348": "Expected a work-in-progress root. This is likely a bug in React. Please file an issue."
349+
"348": "Expected a work-in-progress root. This is a bug in React. Please file an issue.",
350+
"349": "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue."
350351
}

0 commit comments

Comments
 (0)