/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import React, {useState} from 'react'; import {plugin} from '../index'; import {DetailSidebar, Layout, usePlugin, useValue} from 'flipper-plugin'; import {useHotkeys} from 'react-hotkeys-hook'; import {Id, Snapshot, UINode} from '../types'; import {PerfStats} from './PerfStats'; import {Tree} from './Tree'; import {Visualization2D} from './Visualization2D'; import {useKeyboardModifiers} from '../hooks/useKeyboardModifiers'; import {Inspector} from './sidebar/Inspector'; export function Component() { const instance = usePlugin(plugin); const rootId = useValue(instance.rootId); const nodes: Map = useValue(instance.nodes); const snapshots: Map = useValue(instance.snapshots); const [showPerfStats, setShowPerfStats] = useState(false); const [selectedNode, setSelectedNode] = useState(undefined); const [hoveredNode, setHoveredNode] = useState(undefined); useHotkeys('ctrl+i', () => setShowPerfStats((show) => !show)); const {ctrlPressed} = useKeyboardModifiers(); function renderSidebar(node: UINode | undefined) { if (!node) { return; } return ( ); } if (showPerfStats) return ; if (rootId) { return ( <> {selectedNode && renderSidebar(nodes.get(selectedNode))} ); } return
Nothing yet
; }