import Delete from '@mui/icons-material/Delete'; import { Paper, IconButton } from '@mui/material'; import React from 'react'; const consoleStyle = { fontSize: '0.75rem', lineHeight: '1.2', }; const SIDELogger: React.FC = () => { const logContainer = React.useRef(null); const handleLog = React.useCallback((level: string, log: string) => { const el = logContainer.current; if (!el) return; const newLogEntry = document.createTextNode( `${new Date().toLocaleTimeString()} [${level}] ${log}\n` ); el.appendChild(newLogEntry); el.scrollTo(0, el.scrollHeight); }, []); // useCallback ensures this function is memoized and not recreated on each render. React.useEffect(() => { window.sideAPI.system.onLog.addListener(handleLog); return () => { window.sideAPI.system.onLog.removeListener(handleLog); }; }, [handleLog]); // Depend on handleLog which is now memoized. return ( <>
{ const el = logContainer.current; if (el) { el.textContent = ''; // Safer and potentially faster than innerHTML } }} >
    
  );
};

export default SIDELogger;