Skip to content

Commit 705055d

Browse files
authored
[DevTools] Enable Suspense tab by default (react#35768)
1 parent 8374c2a commit 705055d

5 files changed

Lines changed: 12 additions & 59 deletions

File tree

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ function createBridgeAndStore() {
167167
supportsClickToInspect: true,
168168
});
169169

170-
store.addListener('enableSuspenseTab', () => {
171-
createSuspensePanel();
172-
});
173-
174170
store.addListener('settingsUpdated', (hookSettings, componentFilters) => {
175171
chrome.storage.local.set({...hookSettings, componentFilters});
176172
});
@@ -565,8 +561,7 @@ function mountReactDevTools() {
565561
createProfilerPanel();
566562
createSourcesEditorPanel();
567563
createElementsInspectPanel();
568-
// Suspense Tab is created via the hook
569-
// TODO(enableSuspenseTab): Create eagerly once Suspense tab is stable
564+
createSuspensePanel();
570565
}
571566

572567
let reactPollingInstance = null;

packages/react-devtools-shared/src/backend/agent.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import type {
3838
ElementType,
3939
} from 'react-devtools-shared/src/frontend/types';
4040
import type {GroupItem} from './views/TraceUpdates/canvas';
41-
import {gte, isReactNativeEnvironment} from './utils';
41+
import {isReactNativeEnvironment} from './utils';
4242
import {
4343
sessionStorageGetItem,
4444
sessionStorageRemoveItem,
@@ -961,16 +961,6 @@ export default class Agent extends EventEmitter<{
961961

962962
rendererInterface.setTraceUpdatesEnabled(this._traceUpdatesEnabled);
963963

964-
const renderer = rendererInterface.renderer;
965-
if (renderer !== null) {
966-
const devRenderer = renderer.bundleType === 1;
967-
const enableSuspenseTab =
968-
devRenderer && gte(renderer.version, '19.3.0-canary');
969-
if (enableSuspenseTab) {
970-
this._bridge.send('enableSuspenseTab');
971-
}
972-
}
973-
974964
// When the renderer is attached, we need to tell it whether
975965
// we remember the previous selection that we'd like to restore.
976966
// It'll start tracking mounts for matches to the last selection path.

packages/react-devtools-shared/src/bridge.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ export type BackendEvents = {
199199
backendInitialized: [],
200200
backendVersion: [string],
201201
bridgeProtocol: [BridgeProtocol],
202-
enableSuspenseTab: [],
203202
extensionBackendInitialized: [],
204203
fastRefreshScheduled: [],
205204
getSavedPreferences: [],

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export default class Store extends EventEmitter<{
143143
backendVersion: [],
144144
collapseNodesByDefault: [],
145145
componentFilters: [],
146-
enableSuspenseTab: [],
147146
error: [Error],
148147
hookSettings: [$ReadOnly<DevToolsHookSettings>],
149148
hostInstanceSelected: [Element['id'] | null],
@@ -239,8 +238,6 @@ export default class Store extends EventEmitter<{
239238
_supportsClickToInspect: boolean = false;
240239
_supportsTimeline: boolean = false;
241240
_supportsTraceUpdates: boolean = false;
242-
// Dynamically set if the renderer supports the Suspense tab.
243-
_supportsSuspenseTab: boolean = false;
244241

245242
_isReloadAndProfileFrontendSupported: boolean = false;
246243
_isReloadAndProfileBackendSupported: boolean = false;
@@ -341,7 +338,6 @@ export default class Store extends EventEmitter<{
341338
bridge.addListener('hookSettings', this.onHookSettings);
342339
bridge.addListener('backendInitialized', this.onBackendInitialized);
343340
bridge.addListener('selectElement', this.onHostInstanceSelected);
344-
bridge.addListener('enableSuspenseTab', this.onEnableSuspenseTab);
345341
}
346342

347343
// This is only used in tests to avoid memory leaks.
@@ -2394,15 +2390,6 @@ export default class Store extends EventEmitter<{
23942390
}
23952391
}
23962392

2397-
get supportsSuspenseTab(): boolean {
2398-
return this._supportsSuspenseTab;
2399-
}
2400-
2401-
onEnableSuspenseTab = (): void => {
2402-
this._supportsSuspenseTab = true;
2403-
this.emit('enableSuspenseTab');
2404-
};
2405-
24062393
// The Store should never throw an Error without also emitting an event.
24072394
// Otherwise Store errors will be invisible to users,
24082395
// but the downstream errors they cause will be reported as bugs.

packages/react-devtools-shared/src/devtools/views/DevTools.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,7 @@ const suspenseTab = {
135135
title: 'React Suspense',
136136
};
137137

138-
const defaultTabs = [componentsTab, profilerTab];
139-
const tabsWithSuspense = [componentsTab, profilerTab, suspenseTab];
140-
141-
function useIsSuspenseTabEnabled(store: Store): boolean {
142-
const subscribe = useCallback(
143-
(onStoreChange: () => void) => {
144-
store.addListener('enableSuspenseTab', onStoreChange);
145-
return () => {
146-
store.removeListener('enableSuspenseTab', onStoreChange);
147-
};
148-
},
149-
[store],
150-
);
151-
return React.useSyncExternalStore(subscribe, () => store.supportsSuspenseTab);
152-
}
138+
const tabs = [componentsTab, profilerTab, suspenseTab];
153139

154140
export default function DevTools({
155141
bridge,
@@ -183,8 +169,6 @@ export default function DevTools({
183169
LOCAL_STORAGE_DEFAULT_TAB_KEY,
184170
defaultTab,
185171
);
186-
const enableSuspenseTab = useIsSuspenseTabEnabled(store);
187-
const tabs = enableSuspenseTab ? tabsWithSuspense : defaultTabs;
188172

189173
let tab = currentTab;
190174

@@ -364,17 +348,15 @@ export default function DevTools({
364348
}
365349
/>
366350
</div>
367-
{enableSuspenseTab && (
368-
<div
369-
className={styles.TabContent}
370-
hidden={tab !== 'suspense'}>
371-
<SuspenseTab
372-
portalContainer={
373-
suspensePortalContainer
374-
}
375-
/>
376-
</div>
377-
)}
351+
<div
352+
className={styles.TabContent}
353+
hidden={tab !== 'suspense'}>
354+
<SuspenseTab
355+
portalContainer={
356+
suspensePortalContainer
357+
}
358+
/>
359+
</div>
378360
</div>
379361
{editorPortalContainer ? (
380362
<EditorPane

0 commit comments

Comments
 (0)