Skip to content

Commit

Permalink
rename nodes & enable store lookup for components tab
Browse files Browse the repository at this point in the history
  • Loading branch information
bl00mber committed May 14, 2020
1 parent 8b4dba8 commit 57bf4db
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('profiling utils', () => {

it('should throw if importing older/unsupported data', () => {
expect(() =>
utils.prepareProfilingDataFrontendFromImport(
utils.prepareProfilingDataFrontendForImport(
({
version: 0,
dataForRoots: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shared/src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function requireTestRenderer(): ReactTestRenderer {
export function exportImportHelper(bridge: FrontendBridge, store: Store): void {
const {
prepareProfilingDataExport,
prepareProfilingDataFrontendFromImport,
prepareProfilingDataFrontendForImport,
} = require('react-devtools-shared/src/devtools/views/Profiler/utils');

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

const profilingDataFrontendImport = prepareProfilingDataFrontendFromImport(
const profilingDataFrontendImport = prepareProfilingDataFrontendForImport(
(parsedProfilingDataExport: any),
);

Expand Down
5 changes: 0 additions & 5 deletions packages/react-devtools-shared/src/devtools/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,6 @@ export default class Store extends EventEmitter<{|
}

getElementByID(id: number): Element | null {
if (
this._profilerStore._dataFrontend &&
this._profilerStore._dataFrontend.imported === true
)
return null;
const element = this._idToElement.get(id);
if (element == null) {
console.warn(`No element found with id "${id}"`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ function ProfilerContextController({children}: Props) {
selectFiberName(name);

// Sync selection to the Components tab for convenience.
if (id !== null) {
if (
id !== null &&
profilingData !== null &&
profilingData.imported === false
) {
const element = store.getElementByID(id);

// Keep in mind that profiling data may be from a previous session.
Expand All @@ -151,7 +155,7 @@ function ProfilerContextController({children}: Props) {
}
}
},
[dispatch, selectFiberID, selectFiberName, store],
[dispatch, selectFiberID, selectFiberName, store, profilingData],
);

const setRootIDAndClearFiber = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ButtonIcon from '../ButtonIcon';
import {StoreContext} from '../context';
import {
prepareProfilingDataExport,
prepareProfilingDataFrontendFromImport,
prepareProfilingDataFrontendForImport,
} from './utils';
import {downloadFile} from '../utils';

Expand Down Expand Up @@ -80,7 +80,7 @@ export default function ProfilingImportExportButtons() {
const profilingDataImport = ((JSON.parse(
raw,
): any): ProfilingDataExport);
profilerStore.profilingData = prepareProfilingDataFrontendFromImport(
profilerStore.profilingData = prepareProfilingDataFrontendForImport(
profilingDataImport,
);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
}

// Converts a Profiling data export into the format required by the Store.
export function prepareProfilingDataFrontendFromImport(
export function prepareProfilingDataFrontendForImport(
profilingDataImport: ProfilingDataExport,
): ProfilingDataFrontend {
const {version} = profilingDataImport;
Expand Down

0 comments on commit 57bf4db

Please sign in to comment.