Skip to content

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Jan 21, 2026

The extension wasn't using the persistested filters until you made changes in the frontend. Now we're using the same approach as the hook settings which means the timings works out to be before React renders. That way we don't have to immediately throw out the devtools backend tree like we usually do when updating component filters.

The alternative would be to use the savedPreferences messages like react-devtools-inline does. react-devtools-inline approach is less complex but would come with two downsides:

  • it comes in while we're profiling when we don't support updating filters
  • it comes in after the initial mount i.e. we always reconcile the full tree twice on initial load

Storing it in the backend means data might desync but that complexity is worth avoiding the two issues above.
If we get synchronization issues in practice we can revisit.

This removes reliance on __REACT_DEVTOOLS_COMPONENT_FILTERS__ in favor of passing a sync value or Promise to initialize instead.

Test plan

  • host Components are unfiltered on reload if no Components are filtered
  • reload&profile shows host Components and doesn't throw
CleanShot.2026-01-21.at.19.40.04.mp4

@meta-cla meta-cla bot added the CLA Signed label Jan 21, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jan 21, 2026
@eps1lon eps1lon force-pushed the sebbie/01-21-_devtools_apply_component_filters_on_initial_load branch from 4cba399 to a33fa0e Compare January 21, 2026 18:06
@eps1lon eps1lon force-pushed the sebbie/01-21-_devtools_apply_component_filters_on_initial_load branch from a33fa0e to f34c5b6 Compare January 21, 2026 18:15
@eps1lon eps1lon requested a review from hoxyq January 21, 2026 18:43
@eps1lon eps1lon marked this pull request as ready for review January 21, 2026 18:44
Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to save filters in local storage? Maybe it can be removed after these changes?

export function setSavedComponentFilters(
componentFilters: Array<ComponentFilter>,
): void {
localStorageSetItem(
LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY,
JSON.stringify(persistableComponentFilters(componentFilters)),
);
}

Comment on lines 365 to 366
savedPreferencesString +
backendFile.toString() +
'\n;' +
backendFile.toString() +
'\n;' +
'ReactDevToolsBackend.initialize();' +
`ReactDevToolsBackend.initialize(${componentFiltersString});` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't work?

initialize(...) receives hook settings as a first argument:

export function initialize(
maybeSettingsOrSettingsPromise?:
| DevToolsHookSettings
| Promise<DevToolsHookSettings>,
shouldStartProfilingNow: boolean = false,
profilingSettings?: ProfilingSettings,
maybeComponentFiltersOrComponentFiltersPromise?:
| Array<ComponentFilter>
| Promise<Array<ComponentFilter>>,
) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test standalone in Safari, by opening fixtures/devtools/standalone/index.html.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Jan 22, 2026

Do we still need to save filters in local storage? Maybe it can be removed after these changes?

It's relevant for the versions that don't have access to chrome.storage.local I believe.

Using the localStorage from the frontend has two downsides:
- it comes in while we're profiling when we don't support updating filters
- it comes in after the initial mount i.e. we always reconcile the full tree twice on initial load

Storing it in the backend means data might desync
but that complexity is worth avoiding the two issues above.
If we get synchronization issues in practice we can revisit.
@eps1lon eps1lon force-pushed the sebbie/01-21-_devtools_apply_component_filters_on_initial_load branch from 3031aae to 43a0ec0 Compare January 22, 2026 18:39
@eps1lon eps1lon requested a review from hoxyq January 22, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants