File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
packages/react-live/src/components/Editor Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -24,16 +24,21 @@ const CodeEditor = (props: Props) => {
24
24
setCode ( props . code ) ;
25
25
} , [ props . code ] ) ;
26
26
27
- useEditable ( editorRef , ( text ) => setCode ( text . slice ( 0 , - 1 ) ) , {
28
- disabled : props . disabled ,
29
- indentation : tabMode === "indentation" ? 2 : undefined ,
30
- } ) ;
27
+ useEditable (
28
+ editorRef ,
29
+ ( text ) => {
30
+ const t = text . slice ( 0 , - 1 ) ;
31
+ setCode ( t ) ;
31
32
32
- useEffect ( ( ) => {
33
- if ( props . onChange ) {
34
- props . onChange ( code ) ;
33
+ if ( props . onChange ) {
34
+ props . onChange ( t ) ;
35
+ }
36
+ } ,
37
+ {
38
+ disabled : props . disabled ,
39
+ indentation : tabMode === "indentation" ? 2 : undefined ,
35
40
}
36
- } , [ code ] ) ;
41
+ ) ;
37
42
38
43
return (
39
44
< div className = { props . className } style = { props . style } >
You can’t perform that action at this time.
0 commit comments