File tree 4 files changed +44
-13
lines changed
4 files changed +44
-13
lines changed Original file line number Diff line number Diff line change 7
7
"codemirror" : " ^5.48.0" ,
8
8
"react" : " ^16.8.6" ,
9
9
"react-bootstrap" : " ^1.0.0-beta.9" ,
10
+ "react-codemirror" : " ^1.0.0" ,
10
11
"react-codemirror2" : " ^6.0.0" ,
11
12
"react-dom" : " ^16.8.6" ,
12
13
"react-router-dom" : " ^5.0.1" ,
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react'
2
2
import 'codemirror/lib/codemirror.css' ;
3
3
import '../App.css'
4
- import { Controlled as CodeMirror } from 'react-codemirror2 '
4
+ import CodeMirror from 'react-codemirror '
5
5
import 'codemirror/mode/javascript/javascript'
6
6
import 'codemirror/theme/dracula.css'
7
7
import Hello from './Hello'
@@ -19,7 +19,7 @@ export default class XML extends Component {
19
19
20
20
updateCode = ( newCode ) => {
21
21
this . setState ( {
22
- code : newCode ,
22
+ code : newCode ,
23
23
} ) ;
24
24
}
25
25
@@ -42,9 +42,7 @@ export default class XML extends Component {
42
42
ref = { this . code }
43
43
value = { this . state . code }
44
44
options = { options }
45
- onBeforeChange = { ( editor , data , code ) => {
46
- this . setState ( { code} ) ;
47
- } }
45
+ onChange = { this . updateCode }
48
46
/>
49
47
< div className = "btn btn-primary p-2 my-3 toggler" onClick = { this . handleSubmit } > Toggle Code Display</ div >
50
48
{ this . state . viewOpToggle &&
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react'
2
2
import 'codemirror/lib/codemirror.css' ;
3
3
import '../App.css'
4
- import { Controlled as CodeMirror } from 'react-codemirror2 '
4
+ import CodeMirror from 'react-codemirror '
5
5
import 'codemirror/mode/xml/xml.js'
6
6
import 'codemirror/theme/dracula.css'
7
7
import Hello from './Hello'
@@ -20,6 +20,7 @@ export default class XML extends Component {
20
20
updateCode = ( newCode ) => {
21
21
this . setState ( {
22
22
code : newCode ,
23
+ // viewOpToggle: true
23
24
} ) ;
24
25
}
25
26
@@ -39,13 +40,11 @@ export default class XML extends Component {
39
40
return (
40
41
< div >
41
42
< CodeMirror
42
- ref = { this . code }
43
- value = { this . state . code }
44
- options = { options }
45
- onBeforeChange = { ( editor , data , code ) => {
46
- this . setState ( { code} ) ;
47
- } }
48
- />
43
+ value = { this . state . code }
44
+ options = { options }
45
+ onChange = { this . updateCode }
46
+ />
47
+
49
48
< div className = "btn btn-primary p-2 my-3 toggler" onClick = { this . handleSubmit } > Toggle Code Display</ div >
50
49
{ this . state . viewOpToggle &&
51
50
< Hello code = { this . state . code } />
You can’t perform that action at this time.
0 commit comments