mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Moved profiling data to ProfilerContext to fix re-import bug
This commit is contained in:
@@ -33,6 +33,7 @@ type Context = {|
|
||||
hasProfilingData: boolean,
|
||||
isProcessingData: boolean,
|
||||
isProfiling: boolean,
|
||||
profilingData: ProfilingDataFrontend | null,
|
||||
startProfiling(value: boolean): void,
|
||||
stopProfiling(value: boolean): void,
|
||||
|
||||
@@ -203,6 +204,7 @@ function ProfilerContextController({ children }: Props) {
|
||||
hasProfilingData,
|
||||
isProcessingData,
|
||||
isProfiling,
|
||||
profilingData,
|
||||
startProfiling,
|
||||
stopProfiling,
|
||||
|
||||
@@ -231,6 +233,7 @@ function ProfilerContextController({ children }: Props) {
|
||||
hasProfilingData,
|
||||
isProcessingData,
|
||||
isProfiling,
|
||||
profilingData,
|
||||
startProfiling,
|
||||
stopProfiling,
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import styles from './ProfilingImportExportButtons.css';
|
||||
import type { ProfilingDataExport } from './types';
|
||||
|
||||
export default function ProfilingImportExportButtons() {
|
||||
const { isProfiling, rootID } = useContext(ProfilerContext);
|
||||
const { isProfiling, profilingData, rootID } = useContext(ProfilerContext);
|
||||
const store = useContext(StoreContext);
|
||||
const { profilerStore } = store;
|
||||
|
||||
@@ -30,17 +30,14 @@ export default function ProfilingImportExportButtons() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profilerStore.profilingData !== null) {
|
||||
const profilingDataExport = prepareProfilingDataExport(
|
||||
profilerStore.profilingData
|
||||
);
|
||||
|
||||
if (profilingData !== null) {
|
||||
const profilingDataExport = prepareProfilingDataExport(profilingData);
|
||||
downloadFile(
|
||||
'profile-data.json',
|
||||
JSON.stringify(profilingDataExport, null, 2)
|
||||
);
|
||||
}
|
||||
}, [rootID, profilerStore.profilingData]);
|
||||
}, [rootID, profilingData]);
|
||||
|
||||
const uploadData = useCallback(() => {
|
||||
if (inputRef.current !== null) {
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
import React, { Fragment, useCallback, useContext } from 'react';
|
||||
import { ProfilerContext } from './ProfilerContext';
|
||||
import { StoreContext } from '../context';
|
||||
|
||||
import styles from './RootSelector.css';
|
||||
|
||||
export default function RootSelector(_: {||}) {
|
||||
const store = useContext(StoreContext);
|
||||
const { rootID, setRootID } = useContext(ProfilerContext);
|
||||
|
||||
const { profilingData } = store.profilerStore;
|
||||
const { profilingData, rootID, setRootID } = useContext(ProfilerContext);
|
||||
|
||||
const options = [];
|
||||
if (profilingData !== null) {
|
||||
|
||||
Reference in New Issue
Block a user