import { ReactNode, useEffect, useRef, useState } from 'preact/compat'; import { playNotificationSound } from '~core/utils'; import { cn } from '~web/utils/helpers'; import { useNotificationsContext } from './data'; import { CloseIcon } from './icons'; import { NotificationTabs } from './notification-tabs'; import { Optimize } from './optimize'; import { OtherVisualization } from './other-visualization'; import { RenderBarChart } from './render-bar-chart'; import { RenderExplanation } from './render-explanation'; import { signalWidgetViews } from '~web/state'; export const DetailsRoutes = () => { const { notificationState, setNotificationState } = useNotificationsContext(); const [dots, setDots] = useState('...'); const containerRef = useRef(null); useEffect(() => { const interval = setInterval(() => { setDots((prev) => { if (prev === '...') return ''; return prev + '.'; }); }, 500); return () => clearInterval(interval); }, []); if (!notificationState.selectedEvent) { return (
Scanning for slowdowns {dots}
{notificationState.events.length !== 0 && (

Click on an item in the{' '} History list to get started

)}

You don't need to keep this panel open for React Scan to record slowdowns

Enable audio alerts to hear a delightful ding every time a large slowdown is recorded

); } switch (notificationState.route) { case 'render-visualization': { return ( ); } case 'render-explanation': { if (!notificationState.selectedFiber) { // todo: dev only throw new Error( 'Invariant: must have selected fiber when viewing render explanation', ); } return ( ); } case 'other-visualization': { return (
); } case 'optimize': { return ( ); } } // exhaustive verification notificationState.route satisfies never; }; const TabLayout = ({ children }: { children: ReactNode }) => { const { notificationState } = useNotificationsContext(); if (!notificationState.selectedEvent) { // todo: dev only throw new Error( 'Invariant: d must have selected event when viewing render explanation', ); } return (
{children}
); };