File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
2
3
3
module . exports = React . createClass ( {
4
+ getInitialState : function ( ) {
5
+ return {
6
+ text : ''
7
+ }
8
+ } ,
4
9
render : function ( ) {
5
10
return < div className = "input-group" >
6
- < input type = "text" className = "form-control" />
11
+ < input
12
+ value = { this . state . text }
13
+ onChange = { this . handleInputChange }
14
+ type = "text"
15
+ className = "form-control" />
7
16
< span className = "input-group-btn" >
8
- < button className = "btn btn-default" type = "button" >
17
+ < button
18
+ onClick = { this . handleClick }
19
+ className = "btn btn-default"
20
+ type = "button" >
9
21
Add
10
22
</ button >
11
23
</ span >
12
24
</ div >
25
+ } ,
26
+ handleClick : function ( ) {
27
+ console . log ( this . state . text ) ;
28
+ } ,
29
+ handleInputChange : function ( event ) {
30
+ this . setState ( { text : event . target . value } ) ;
13
31
}
14
32
} ) ;
You can’t perform that action at this time.
0 commit comments