import * as React from 'react'; import { Stack, Panel, PrimaryButton } from '@fluentui/react'; import MonacoEditor from 'react-monaco-editor'; import { caclMonacoEditorHeight } from '@static/function'; import '@style/logPanel.scss'; interface LogPanelProps { hideConfigPanel: () => void; panelName: string; panelContent: string; } interface LogPanelState { panelInnerHeight: number; } /** * search space * config * retiarii parameter * panel */ class PanelMonacoEditor extends React.Component { constructor(props: LogPanelProps) { super(props); this.state = { panelInnerHeight: window.innerHeight }; } // use arrow function for change window size met error: this.setState is not a function setLogPanelHeight = (): void => { this.setState(() => ({ panelInnerHeight: window.innerHeight, innerWidth: window.innerWidth })); }; async componentDidMount(): Promise { window.addEventListener('resize', this.setLogPanelHeight); } componentWillUnmount(): void { window.removeEventListener('resize', this.setLogPanelHeight); } render(): React.ReactNode { const { hideConfigPanel, panelName, panelContent } = this.props; const { panelInnerHeight } = this.state; const monacoEditorHeight = caclMonacoEditorHeight(panelInnerHeight); return (
{panelName}
); } } export default PanelMonacoEditor;