@@ -18,6 +18,7 @@ import {
18
18
import ReactVersion from 'shared/ReactVersion' ;
19
19
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber' ;
20
20
import { SCHEDULING_PROFILER_VERSION } from 'react-devtools-timeline/src/constants' ;
21
+ import isArray from 'shared/isArray' ;
21
22
22
23
import {
23
24
getLabelForLane as getLabelForLane_old ,
@@ -105,11 +106,18 @@ function markInternalModuleRanges() {
105
106
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ . getInternalModuleRanges === 'function'
106
107
) {
107
108
const ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__ . getInternalModuleRanges ( ) ;
108
- for ( let i = 0 ; i < ranges . length ; i ++ ) {
109
- const [ startStackFrame , stopStackFrame ] = ranges [ i ] ;
110
-
111
- markAndClear ( `--react-internal-module-start-${ startStackFrame } ` ) ;
112
- markAndClear ( `--react-internal-module-stop-${ stopStackFrame } ` ) ;
109
+ // This check would not be required,
110
+ // except that it's possible for things to override __REACT_DEVTOOLS_GLOBAL_HOOK__.
111
+ if ( isArray ( ranges ) ) {
112
+ for ( let i = 0 ; i < ranges . length ; i ++ ) {
113
+ const range = ranges [ i ] ;
114
+ if ( isArray ( range ) && range . length === 2 ) {
115
+ const [ startStackFrame , stopStackFrame ] = ranges [ i ] ;
116
+
117
+ markAndClear ( `--react-internal-module-start-${ startStackFrame } ` ) ;
118
+ markAndClear ( `--react-internal-module-stop-${ stopStackFrame } ` ) ;
119
+ }
120
+ }
113
121
}
114
122
}
115
123
}
0 commit comments