web: CodeArea

This commit is contained in:
greg 2017-09-20 23:46:46 -07:00
parent 10b1864680
commit d4aec19c71
2 changed files with 28 additions and 5 deletions

View File

@ -5,10 +5,6 @@
<body>
<div id="main">
</div>
Type your source code into here:
<textarea class="code-input">
</textarea>
<script src="bundle.js"></script>
</body>
</html>

View File

@ -1,10 +1,37 @@
const React = require("react");
const ReactDOM = require("react-dom");
class CodeArea extends React.Component {
constructor(props) {
super(props);
this.state = {value: ""};
this.handleChange = this.handleChange.bind(this);
this.submit = this.submit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
submit(event) {
console.log("This", this.state.value);
}
render() {
return (<div>
<textarea value={ this.state.value } onChange={this.handleChange}>
</textarea>
<button onClick={ this.submit }>Run!</button>
</div>);
}
}
const main = (<div>
<h1>Schala web input</h1>
<p>Write your source code here</p>
<CodeArea/>
</div>);
const rootDom = document.getElementById("main");
ReactDOM.render(<h1>Schala web input</h1>, rootDom);
ReactDOM.render(main, rootDom);