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