-
Notifications
You must be signed in to change notification settings - Fork 28
/
live-editor.js
39 lines (32 loc) · 854 Bytes
/
live-editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var React = require("react");
var CodeMirrorEditor = require("./code-mirror-editor");
var ComponentPreview = require("./live-compile");
var ReactPlayground = React.createClass({
propTypes: {
codeText: React.PropTypes.string.isRequired
},
getInitialState: function() {
return {
code: this.props.codeText
};
},
handleCodeChange: function(code) {
this.setState({ code });
},
render: function() {
const {code} = this.state;
return <div className="playground">
<div className="playgroundCode">
<CodeMirrorEditor
onChange={this.handleCodeChange}
className="playgroundStage"
codeText={code}
/>
</div>
<div className="playgroundPreview">
<ComponentPreview code={code} />
</div>
</div>;
},
});
module.exports = ReactPlayground;