From a35b3bb8cacb6f8108a7459fd68947cc425d7587 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Thu, 20 Jun 2024 20:20:41 +0100 Subject: [PATCH] refactor[react-devtools/extensions]: dont debounce cleanup logic on navigation --- packages/react-devtools-extensions/src/main/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js index 5422567db79fc..2a4e9b91f740a 100644 --- a/packages/react-devtools-extensions/src/main/index.js +++ b/packages/react-devtools-extensions/src/main/index.js @@ -412,13 +412,16 @@ chrome.devtools.network.onNavigated.addListener(syncSavedPreferences); // into subscribing to the same events from Bridge and window multiple times // In this case, we will handle `operations` event twice or more and user will see // `Cannot add node "1" because a node with that id is already in the Store.` -const debouncedOnNavigatedListener = debounce(() => { +const debouncedMountReactDevToolsCallback = debounce(mountReactDevToolsWhenReactHasLoaded, 500); + +// Clean up everything, but start mounting React DevTools panels if user stays at this page +function onNavigatedToOtherPage() { performInTabNavigationCleanup(); - mountReactDevToolsWhenReactHasLoaded(); -}, 500); + debouncedMountReactDevToolsCallback(); +} // Cleanup previous page state and remount everything -chrome.devtools.network.onNavigated.addListener(debouncedOnNavigatedListener); +chrome.devtools.network.onNavigated.addListener(onNavigatedToOtherPage); // Should be emitted when browser DevTools are closed if (__IS_FIREFOX__) {