-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (36 loc) · 1.27 KB
/
app.js
File metadata and controls
37 lines (36 loc) · 1.27 KB
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
/** @jsx React.DOM */
var Wrapper = React.createClass({
getInitialState: function () {
return {
text: '',
length: 0
}
},
handleChange: function (event) {
this.setState({text: event.target.value});
},
calc: function () {
this.setState({length: this.state.text.length});
},
reset: function () {
this.setState(this.getInitialState());
},
render: function () {
return (
<div>
<div className='form-group'>
<label>Text</label>
<input type='text' className='form-control' id='text' onChange={this.handleChange} value={this.state.text} />
</div>
<div className='form-group'>
<button type='submit' className='btn btn-default' id='calc' onClick={this.calc}>Submit</button>
<button type='reset' className='btn btn-default' id='reset' onClick={this.reset}>Reset</button>
</div>
<div className='form-group'>
Text is currently <span id='length'>{this.state.length}</span> characters long.
</div>
</div>
);
}
});
React.render(<Wrapper/>, document.getElementById('container'));