@@ -18,6 +18,7 @@ import {
1818import ReactVersion from 'shared/ReactVersion' ;
1919import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber' ;
2020import { SCHEDULING_PROFILER_VERSION } from 'react-devtools-timeline/src/constants' ;
21+ import isArray from 'shared/isArray' ;
2122
2223import {
2324 getLabelForLane as getLabelForLane_old ,
@@ -105,11 +106,18 @@ function markInternalModuleRanges() {
105106 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ . getInternalModuleRanges === 'function'
106107 ) {
107108 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+ }
113121 }
114122 }
115123}
0 commit comments