Skip to content

Commit a35b3bb

Browse files
committed
refactor[react-devtools/extensions]: dont debounce cleanup logic on navigation
1 parent a555419 commit a35b3bb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • packages/react-devtools-extensions/src/main

packages/react-devtools-extensions/src/main/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,16 @@ chrome.devtools.network.onNavigated.addListener(syncSavedPreferences);
412412
// into subscribing to the same events from Bridge and window multiple times
413413
// In this case, we will handle `operations` event twice or more and user will see
414414
// `Cannot add node "1" because a node with that id is already in the Store.`
415-
const debouncedOnNavigatedListener = debounce(() => {
415+
const debouncedMountReactDevToolsCallback = debounce(mountReactDevToolsWhenReactHasLoaded, 500);
416+
417+
// Clean up everything, but start mounting React DevTools panels if user stays at this page
418+
function onNavigatedToOtherPage() {
416419
performInTabNavigationCleanup();
417-
mountReactDevToolsWhenReactHasLoaded();
418-
}, 500);
420+
debouncedMountReactDevToolsCallback();
421+
}
419422

420423
// Cleanup previous page state and remount everything
421-
chrome.devtools.network.onNavigated.addListener(debouncedOnNavigatedListener);
424+
chrome.devtools.network.onNavigated.addListener(onNavigatedToOtherPage);
422425

423426
// Should be emitted when browser DevTools are closed
424427
if (__IS_FIREFOX__) {

0 commit comments

Comments
 (0)