File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -193,15 +193,16 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
193
193
editorRef . current . layout ( )
194
194
} , [ width , windowHeight ] )
195
195
196
- useEffect ( ( ) => {
196
+ const setCode = ( value : string ) => {
197
+ dispatch ( { type : 'setCode' , value } )
197
198
if ( onChange ) {
198
- onChange ( state . code )
199
+ onChange ( value )
199
200
}
200
- } , [ state . code ] )
201
+ }
201
202
202
203
useEffect ( ( ) => {
203
204
if ( noParsing ) {
204
- dispatch ( { type : ' setCode' , value } )
205
+ setCode ( value )
205
206
206
207
return
207
208
}
@@ -220,7 +221,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
220
221
if ( obj ) {
221
222
final = state . mode === 'json' ? JSON . stringify ( obj , null , tabSize ) : YAMLStringify ( obj )
222
223
}
223
- dispatch ( { type : ' setCode' , value : final } )
224
+ setCode ( final )
224
225
} , [ value , noParsing ] )
225
226
226
227
useEffect ( ( ) => {
@@ -234,12 +235,12 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
234
235
} , [ focus ] )
235
236
236
237
function handleOnChange ( newValue , e ) {
237
- dispatch ( { type : ' setCode' , value : newValue } )
238
+ setCode ( newValue )
238
239
}
239
240
240
241
function handleLanguageChange ( mode : 'json' | 'yaml' ) {
241
242
dispatch ( { type : 'changeLanguage' , value : mode } )
242
- dispatch ( { type : ' setCode' , value : mode === 'json' ? json : yamlCode } )
243
+ setCode ( mode === 'json' ? json : yamlCode )
243
244
}
244
245
245
246
const options : monaco . editor . IEditorConstructionOptions = {
You can’t perform that action at this time.
0 commit comments