@@ -1189,15 +1189,25 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1189
1189
capturedErrors = new Map ( ) ;
1190
1190
}
1191
1191
1192
- capturedErrors . set ( boundary , {
1192
+ const capturedError = {
1193
1193
componentName,
1194
1194
componentStack,
1195
1195
error,
1196
1196
errorBoundary : errorBoundaryFound ? boundary . stateNode : null ,
1197
1197
errorBoundaryFound,
1198
1198
errorBoundaryName,
1199
1199
willRetry,
1200
- } ) ;
1200
+ } ;
1201
+
1202
+ capturedErrors . set ( boundary , capturedError ) ;
1203
+
1204
+ try {
1205
+ logCapturedError ( capturedError ) ;
1206
+ } catch ( e ) {
1207
+ // Prevent cycle if logCapturedError() throws.
1208
+ // A cycle may still occur if logCapturedError renders a component that throws.
1209
+ console . error ( e ) ;
1210
+ }
1201
1211
1202
1212
// If we're in the commit phase, defer scheduling an update on the
1203
1213
// boundary until after the commit is complete
@@ -1261,15 +1271,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1261
1271
'bug in React. Please file an issue.' ,
1262
1272
) ;
1263
1273
1264
- const error = capturedError . error ;
1265
- try {
1266
- logCapturedError ( capturedError ) ;
1267
- } catch ( e ) {
1268
- // Prevent cycle if logCapturedError() throws.
1269
- // A cycle may still occur if logCapturedError renders a component that throws.
1270
- console . error ( e ) ;
1271
- }
1272
-
1273
1274
switch ( effectfulFiber . tag ) {
1274
1275
case ClassComponent :
1275
1276
const instance = effectfulFiber . stateNode ;
@@ -1280,14 +1281,14 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1280
1281
1281
1282
// Allow the boundary to handle the error, usually by scheduling
1282
1283
// an update to itself
1283
- instance . componentDidCatch ( error , info ) ;
1284
+ instance . componentDidCatch ( capturedError . error , info ) ;
1284
1285
return ;
1285
1286
case HostRoot :
1286
1287
if ( firstUncaughtError === null ) {
1287
1288
// If this is the host container, we treat it as a no-op error
1288
1289
// boundary. We'll throw the first uncaught error once it's safe to
1289
1290
// do so, at the end of the batch.
1290
- firstUncaughtError = error ;
1291
+ firstUncaughtError = capturedError . error ;
1291
1292
}
1292
1293
return ;
1293
1294
default :
0 commit comments