Migrate framework events backing data structure to datasource

Summary: This will allow us to build a nice table easily.

Reviewed By: lblasa

Differential Revision: D47520029

fbshipit-source-id: 3cdd776533b66688329171eb29b892e0b9153540
This commit is contained in:
Luke De Feo
2023-07-19 08:58:20 -07:00
committed by Facebook GitHub Bot
parent 16480a95f3
commit 7812dae764
6 changed files with 46 additions and 53 deletions

View File

@@ -42,7 +42,6 @@ export const Inspector: React.FC<Props> = ({
}) => {
const instance = usePlugin(plugin);
const selectedNodeId = useValue(instance.uiState.selectedNode)?.id;
const frameworkEvents = useValue(instance.frameworkEvents);
const selectedNode = selectedNodeId ? nodes.get(selectedNodeId) : undefined;
if (!selectedNode) {
@@ -50,8 +49,8 @@ export const Inspector: React.FC<Props> = ({
}
const selectedFrameworkEvents = selectedNodeId
? frameworkEvents?.get(selectedNodeId)
: undefined;
? instance.frameworkEvents.getAllRecordsByIndex({nodeId: selectedNodeId})
: [];
return (
<Layout.Container gap pad>
@@ -108,7 +107,7 @@ export const Inspector: React.FC<Props> = ({
/>
</Tab>
)}
{selectedFrameworkEvents && (
{selectedFrameworkEvents?.length > 0 && (
<Tab
key={'events'}
tab={

View File

@@ -15,7 +15,7 @@ import {StackTraceInspector} from './StackTraceInspector';
type Props = {
node: UINode;
events: FrameworkEvent[];
events: readonly FrameworkEvent[];
showExtra?: (element: ReactNode) => void;
};
export const FrameworkEventsInspector: React.FC<Props> = ({
@@ -41,7 +41,7 @@ export const FrameworkEventsInspector: React.FC<Props> = ({
};
const hasStacktrace = (event: FrameworkEvent) => {
return event.attribution?.type === 'stacktrace';
return event?.attribution?.type === 'stacktrace';
};
return (