Skip to content

Commit 57bf4db

Browse files
committed
rename nodes & enable store lookup for components tab
1 parent 8b4dba8 commit 57bf4db

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

packages/react-devtools-shared/src/__tests__/profilingUtils-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('profiling utils', () => {
1616

1717
it('should throw if importing older/unsupported data', () => {
1818
expect(() =>
19-
utils.prepareProfilingDataFrontendFromImport(
19+
utils.prepareProfilingDataFrontendForImport(
2020
({
2121
version: 0,
2222
dataForRoots: [],

packages/react-devtools-shared/src/__tests__/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export function requireTestRenderer(): ReactTestRenderer {
173173
export function exportImportHelper(bridge: FrontendBridge, store: Store): void {
174174
const {
175175
prepareProfilingDataExport,
176-
prepareProfilingDataFrontendFromImport,
176+
prepareProfilingDataFrontendForImport,
177177
} = require('react-devtools-shared/src/devtools/views/Profiler/utils');
178178

179179
const {profilerStore} = store;
@@ -194,7 +194,7 @@ export function exportImportHelper(bridge: FrontendBridge, store: Store): void {
194194
);
195195
const parsedProfilingDataExport = JSON.parse(serializedProfilingDataExport);
196196

197-
const profilingDataFrontendImport = prepareProfilingDataFrontendFromImport(
197+
const profilingDataFrontendImport = prepareProfilingDataFrontendForImport(
198198
(parsedProfilingDataExport: any),
199199
);
200200

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

-5
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ export default class Store extends EventEmitter<{|
416416
}
417417

418418
getElementByID(id: number): Element | null {
419-
if (
420-
this._profilerStore._dataFrontend &&
421-
this._profilerStore._dataFrontend.imported === true
422-
)
423-
return null;
424419
const element = this._idToElement.get(id);
425420
if (element == null) {
426421
console.warn(`No element found with id "${id}"`);

packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ function ProfilerContextController({children}: Props) {
138138
selectFiberName(name);
139139

140140
// Sync selection to the Components tab for convenience.
141-
if (id !== null) {
141+
if (
142+
id !== null &&
143+
profilingData !== null &&
144+
profilingData.imported === false
145+
) {
142146
const element = store.getElementByID(id);
143147

144148
// Keep in mind that profiling data may be from a previous session.
@@ -151,7 +155,7 @@ function ProfilerContextController({children}: Props) {
151155
}
152156
}
153157
},
154-
[dispatch, selectFiberID, selectFiberName, store],
158+
[dispatch, selectFiberID, selectFiberName, store, profilingData],
155159
);
156160

157161
const setRootIDAndClearFiber = useCallback(

packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import ButtonIcon from '../ButtonIcon';
1616
import {StoreContext} from '../context';
1717
import {
1818
prepareProfilingDataExport,
19-
prepareProfilingDataFrontendFromImport,
19+
prepareProfilingDataFrontendForImport,
2020
} from './utils';
2121
import {downloadFile} from '../utils';
2222

@@ -80,7 +80,7 @@ export default function ProfilingImportExportButtons() {
8080
const profilingDataImport = ((JSON.parse(
8181
raw,
8282
): any): ProfilingDataExport);
83-
profilerStore.profilingData = prepareProfilingDataFrontendFromImport(
83+
profilerStore.profilingData = prepareProfilingDataFrontendForImport(
8484
profilingDataImport,
8585
);
8686
} catch (error) {

packages/react-devtools-shared/src/devtools/views/Profiler/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
103103
}
104104

105105
// Converts a Profiling data export into the format required by the Store.
106-
export function prepareProfilingDataFrontendFromImport(
106+
export function prepareProfilingDataFrontendForImport(
107107
profilingDataImport: ProfilingDataExport,
108108
): ProfilingDataFrontend {
109109
const {version} = profilingDataImport;

0 commit comments

Comments
 (0)