@@ -35,9 +35,12 @@ export const MonacoEditor: FC<TMonacoEditorProps> = ({
3535 const socketRef = useRef < WebSocket | null > ( null )
3636 const editorRef = useRef < monaco . editor . IStandaloneCodeEditor | null > ( null )
3737
38+ const [ editorReady , setEditorReady ] = useState < boolean > ( false )
39+
3840 // Handle editor mount
3941 const handleEditorDidMount = ( editor : monaco . editor . IStandaloneCodeEditor ) => {
4042 editorRef . current = editor
43+ setEditorReady ( true )
4144 }
4245
4346 // Append content to editor
@@ -56,6 +59,10 @@ export const MonacoEditor: FC<TMonacoEditorProps> = ({
5659 }
5760
5861 useEffect ( ( ) => {
62+ if ( ! editorReady ) {
63+ return undefined
64+ }
65+
5966 const socket = new WebSocket ( endpoint )
6067 socketRef . current = socket
6168
@@ -96,7 +103,7 @@ export const MonacoEditor: FC<TMonacoEditorProps> = ({
96103 socket . close ( )
97104 }
98105 }
99- } , [ endpoint , namespace , podName , container , previous ] )
106+ } , [ endpoint , namespace , podName , container , previous , editorReady ] )
100107
101108 return (
102109 < >
@@ -133,7 +140,7 @@ export const MonacoEditor: FC<TMonacoEditorProps> = ({
133140 defaultLanguage = "plaintext"
134141 language = "plaintext"
135142 width = "100%"
136- height = { `calc(100vh - ${ substractHeight } px` }
143+ height = { `calc(100vh - ${ substractHeight } px) ` }
137144 theme = { theme === 'dark' ? 'vs-dark' : theme === undefined ? 'vs-dark' : 'vs' }
138145 options = { {
139146 theme : theme === 'dark' ? 'vs-dark' : theme === undefined ? 'vs-dark' : 'vs' ,
0 commit comments