@@ -43,6 +43,7 @@ import {
43
43
} from './constants' ;
44
44
import {
45
45
ComponentFilterElementType ,
46
+ ComponentFilterLocation ,
46
47
ElementTypeHostComponent ,
47
48
} from './frontend/types' ;
48
49
import {
@@ -339,7 +340,8 @@ export function getSavedComponentFilters(): Array<ComponentFilter> {
339
340
LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY ,
340
341
) ;
341
342
if ( raw != null ) {
342
- return JSON . parse ( raw ) ;
343
+ const parsedFilters : Array < ComponentFilter > = JSON . parse ( raw ) ;
344
+ return filterOutLocationComponentFilters ( parsedFilters ) ;
343
345
}
344
346
} catch (error) { }
345
347
return getDefaultComponentFilters();
@@ -350,10 +352,27 @@ export function setSavedComponentFilters(
350
352
): void {
351
353
localStorageSetItem (
352
354
LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY ,
353
- JSON . stringify ( componentFilters ) ,
355
+ JSON . stringify ( filterOutLocationComponentFilters ( componentFilters ) ) ,
354
356
) ;
355
357
}
356
358
359
+ // Following __debugSource removal from Fiber, the new approach for finding the source location
360
+ // of a component, represented by the Fiber, is based on lazily generating and parsing component stack frames
361
+ // To find the original location, React DevTools will perform symbolication, source maps are required for that.
362
+ // In order to start filtering Fibers, we need to find location for all of them, which can't be done lazily.
363
+ // Eager symbolication can become quite expensive for large applications.
364
+ export function filterOutLocationComponentFilters(
365
+ componentFilters: Array< ComponentFilter > ,
366
+ ): Array< ComponentFilter > {
367
+ // This is just an additional check to preserve the previous state
368
+ // Filters can be stored on the backend side or in user land (in a window object)
369
+ if ( ! Array . isArray ( componentFilters ) ) {
370
+ return componentFilters ;
371
+ }
372
+
373
+ return componentFilters.filter(f => f . type !== ComponentFilterLocation ) ;
374
+ }
375
+
357
376
function parseBool ( s : ?string ) : ?boolean {
358
377
if ( s === 'true' ) {
359
378
return true ;
0 commit comments