Skip to content

Commit

Permalink
refactor[react-devtools/extensions]: dont debounce cleanup logic on n…
Browse files Browse the repository at this point in the history
…avigation
  • Loading branch information
hoxyq committed Jun 20, 2024
1 parent a555419 commit a35b3bb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/react-devtools-extensions/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__) {
Expand Down

0 comments on commit a35b3bb

Please sign in to comment.