@@ -43,6 +43,7 @@ import {
4343} from './constants' ;
4444import {
4545 ComponentFilterElementType ,
46+ ComponentFilterLocation ,
4647 ElementTypeHostComponent ,
4748} from './frontend/types' ;
4849import {
@@ -339,7 +340,8 @@ export function getSavedComponentFilters(): Array<ComponentFilter> {
339340 LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY ,
340341 ) ;
341342 if ( raw != null ) {
342- return JSON . parse ( raw ) ;
343+ const parsedFilters : Array < ComponentFilter > = JSON . parse ( raw ) ;
344+ return filterOutLocationComponentFilters ( parsedFilters ) ;
343345 }
344346 } catch (error) { }
345347 return getDefaultComponentFilters();
@@ -350,10 +352,27 @@ export function setSavedComponentFilters(
350352): void {
351353 localStorageSetItem (
352354 LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY ,
353- JSON . stringify ( componentFilters ) ,
355+ JSON . stringify ( filterOutLocationComponentFilters ( componentFilters ) ) ,
354356 ) ;
355357}
356358
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+
357376function parseBool ( s : ?string ) : ?boolean {
358377 if ( s === 'true' ) {
359378 return true ;
0 commit comments