9
9
10
10
import type { LazyComponent } from 'react/src/ReactLazy' ;
11
11
12
- import { enableComponentStackLocations } from 'shared/ReactFeatureFlags' ;
13
-
14
12
import {
15
13
REACT_SUSPENSE_TYPE ,
16
14
REACT_SUSPENSE_LIST_TYPE ,
@@ -28,30 +26,26 @@ import DefaultPrepareStackTrace from 'shared/DefaultPrepareStackTrace';
28
26
let prefix ;
29
27
let suffix ;
30
28
export function describeBuiltInComponentFrame ( name : string ) : string {
31
- if ( enableComponentStackLocations ) {
32
- if ( prefix === undefined ) {
33
- // Extract the VM specific prefix used by each line.
34
- try {
35
- throw Error ( ) ;
36
- } catch ( x ) {
37
- const match = x . stack . trim ( ) . match ( / \n ( * ( a t ) ? ) / ) ;
38
- prefix = ( match && match [ 1 ] ) || '' ;
39
- suffix =
40
- x . stack . indexOf ( '\n at' ) > - 1
41
- ? // V8
42
- ' (<anonymous>)'
43
- : // JSC/Spidermonkey
44
- x . stack . indexOf ( '@' ) > - 1
45
- ? '@unknown:0:0'
46
- : // Other
47
- '' ;
48
- }
29
+ if ( prefix === undefined ) {
30
+ // Extract the VM specific prefix used by each line.
31
+ try {
32
+ throw Error ( ) ;
33
+ } catch ( x ) {
34
+ const match = x . stack . trim ( ) . match ( / \n ( * ( a t ) ? ) / ) ;
35
+ prefix = ( match && match [ 1 ] ) || '' ;
36
+ suffix =
37
+ x . stack . indexOf ( '\n at' ) > - 1
38
+ ? // V8
39
+ ' (<anonymous>)'
40
+ : // JSC/Spidermonkey
41
+ x . stack . indexOf ( '@' ) > - 1
42
+ ? '@unknown:0:0'
43
+ : // Other
44
+ '' ;
49
45
}
50
- // We use the prefix to ensure our stacks line up with native stack frames.
51
- return '\n' + prefix + name + suffix ;
52
- } else {
53
- return describeComponentFrame ( name ) ;
54
46
}
47
+ // We use the prefix to ensure our stacks line up with native stack frames.
48
+ return '\n' + prefix + name + suffix ;
55
49
}
56
50
57
51
export function describeDebugInfoFrame ( name : string , env : ?string ) : string {
@@ -296,28 +290,12 @@ export function describeNativeComponentFrame(
296
290
return syntheticFrame ;
297
291
}
298
292
299
- function describeComponentFrame ( name : null | string ) {
300
- return '\n in ' + ( name || 'Unknown' ) ;
301
- }
302
-
303
293
export function describeClassComponentFrame ( ctor : Function ) : string {
304
- if ( enableComponentStackLocations ) {
305
- return describeNativeComponentFrame ( ctor , true ) ;
306
- } else {
307
- return describeFunctionComponentFrame ( ctor ) ;
308
- }
294
+ return describeNativeComponentFrame ( ctor , true ) ;
309
295
}
310
296
311
297
export function describeFunctionComponentFrame ( fn : Function ) : string {
312
- if ( enableComponentStackLocations ) {
313
- return describeNativeComponentFrame ( fn , false ) ;
314
- } else {
315
- if ( ! fn ) {
316
- return '' ;
317
- }
318
- const name = fn . displayName || fn . name || null ;
319
- return describeComponentFrame ( name ) ;
320
- }
298
+ return describeNativeComponentFrame ( fn , false ) ;
321
299
}
322
300
323
301
function shouldConstruct ( Component : Function ) {
@@ -334,11 +312,7 @@ export function describeUnknownElementTypeFrameInDEV(type: any): string {
334
312
return '' ;
335
313
}
336
314
if ( typeof type === 'function' ) {
337
- if ( enableComponentStackLocations ) {
338
- return describeNativeComponentFrame ( type , shouldConstruct ( type ) ) ;
339
- } else {
340
- return describeFunctionComponentFrame ( type ) ;
341
- }
315
+ return describeNativeComponentFrame ( type , shouldConstruct ( type ) ) ;
342
316
}
343
317
if ( typeof type === 'string' ) {
344
318
return describeBuiltInComponentFrame ( type ) ;
0 commit comments