@samitouri / QOS-React-2 / commits / 060505e9dc

Fix misapplying prod error opt-out (#24688)

The eslint-disable-next-line opt out for prod error minification was not properly working. In the build a replacable error was output even though it was not failing the build. This change refactors the code to avoid the erroneous behavior but a fix for the lint may be better

Josh Story committed Jun 8, 2022 at 09:49 UTC 060505e9dce2f3d5d9d67c2a9415b94e5b0ca291
2 files changed +22 -16
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+11 -8
@@ -2593,14 +2593,17 @@ function updateDehydratedSuspenseComponent(
2593 ({digest} = getSuspenseInstanceFallbackErrorDetails(suspenseInstance));
2594 }
2595
2596 - const error = message
2597 - ? // eslint-disable-next-line react-internal/prod-error-codes
2598 - new Error(message)
2599 - : new Error(
2600 - 'The server could not finish this Suspense boundary, likely ' +
2601 - 'due to an error during server rendering. Switched to ' +
2602 - 'client rendering.',
2603 - );
2596 + let error;
2597 + if (message) {
2598 + // eslint-disable-next-line react-internal/prod-error-codes
2599 + error = new Error(message);
2600 + } else {
2601 + error = new Error(
2602 + 'The server could not finish this Suspense boundary, likely ' +
2603 + 'due to an error during server rendering. Switched to ' +
2604 + 'client rendering.',
2605 + );
2606 + }
2607 const capturedValue = createCapturedValue(error, digest, stack);
2608 return retrySuspenseComponentWithoutHydrating(
2609 current,
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+11 -8
@@ -2593,14 +2593,17 @@ function updateDehydratedSuspenseComponent(
2593 ({digest} = getSuspenseInstanceFallbackErrorDetails(suspenseInstance));
2594 }
2595
2596 - const error = message
2597 - ? // eslint-disable-next-line react-internal/prod-error-codes
2598 - new Error(message)
2599 - : new Error(
2600 - 'The server could not finish this Suspense boundary, likely ' +
2601 - 'due to an error during server rendering. Switched to ' +
2602 - 'client rendering.',
2603 - );
2596 + let error;
2597 + if (message) {
2598 + // eslint-disable-next-line react-internal/prod-error-codes
2599 + error = new Error(message);
2600 + } else {
2601 + error = new Error(
2602 + 'The server could not finish this Suspense boundary, likely ' +
2603 + 'due to an error during server rendering. Switched to ' +
2604 + 'client rendering.',
2605 + );
2606 + }
2607 const capturedValue = createCapturedValue(error, digest, stack);
2608 return retrySuspenseComponentWithoutHydrating(
2609 current,