@@ -74,17 +74,17 @@ const MonacoEditor = ({
7474 } , [ value , language , theme , isReadOnly ] ) ;
7575
7676 const disposeEditor = useCallback ( ( ) => {
77- onWillUnmount ( editorRef . current ) ;
77+ onWillUnmount ( editorRef . current , monaco ) ;
7878 subscriptionRef . current ?. dispose ( ) ;
7979 editorRef . current . getModel ( ) ?. dispose ( ) ;
8080 editorRef . current . dispose ( ) ;
8181 } , [ onWillUnmount ] ) ;
8282
8383 // disposing of Monaco Editor
84- useMount ( ( ) => ( ) => {
85- if ( editorRef . current ) {
86- disposeEditor ( ) ;
87- }
84+ useMount ( ( ) => {
85+ return ( ) => {
86+ if ( editorRef . current ) disposeEditor ( ) ;
87+ } ;
8888 } ) ;
8989
9090 // defining the custom themes and setting the active one
@@ -134,9 +134,13 @@ const MonacoEditor = ({
134134 ) ;
135135
136136 // settings the theme if changed
137- useEffect ( ( ) => {
138- monaco . editor . setTheme ( theme ) ;
139- } , [ theme ] ) ;
137+ useUpdate (
138+ ( ) => {
139+ monaco . editor . setTheme ( theme ) ;
140+ } ,
141+ [ theme ] ,
142+ isEditorReady
143+ ) ;
140144
141145 // register listener for validation markers
142146 useEffect ( ( ) => {
@@ -188,7 +192,7 @@ const MonacoEditor = ({
188192
189193 // creating Editor instance as last effect
190194 useEffect ( ( ) => {
191- if ( ! isEditorReady && containerRef . current ) {
195+ if ( ! isEditorReady ) {
192196 createEditor ( ) ;
193197 }
194198 } , [ isEditorReady , createEditor ] ) ;
0 commit comments