File tree 3 files changed +21
-15
lines changed
3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,12 @@ var TodoApp2 = React.createClass({
34
34
35
35
handleSubmit : function ( e ) {
36
36
e . preventDefault ( ) ;
37
- this . firebaseRef . push ( {
38
- text : this . state . text
39
- } ) ;
40
- this . setState ( { text : "" } ) ;
37
+ if ( this . state . text ) {
38
+ this . firebaseRef . push ( {
39
+ text : this . state . text
40
+ } ) ;
41
+ this . setState ( { text : "" } ) ;
42
+ }
41
43
} ,
42
44
43
45
render : function ( ) {
Original file line number Diff line number Diff line change @@ -25,10 +25,12 @@ var TodoApp3 = React.createClass({
25
25
26
26
handleSubmit : function ( e ) {
27
27
e . preventDefault ( ) ;
28
- this . firebaseRefs [ "items" ] . push ( {
29
- text : this . state . text
30
- } ) ;
31
- this . setState ( { text : "" } ) ;
28
+ if ( this . state . text ) {
29
+ this . firebaseRefs [ "items" ] . push ( {
30
+ text : this . state . text
31
+ } ) ;
32
+ this . setState ( { text : "" } ) ;
33
+ }
32
34
} ,
33
35
34
36
render : function ( ) {
Original file line number Diff line number Diff line change @@ -19,13 +19,15 @@ var TodoApp1 = React.createClass({
19
19
20
20
handleSubmit : function ( e ) {
21
21
e . preventDefault ( ) ;
22
- var nextItems = this . state . items . concat ( [ {
23
- text : this . state . text
24
- } ] ) ;
25
- this . setState ( {
26
- items : nextItems ,
27
- text : ""
28
- } ) ;
22
+ if ( this . state . text ) {
23
+ var nextItems = this . state . items . concat ( [ {
24
+ text : this . state . text
25
+ } ] ) ;
26
+ this . setState ( {
27
+ items : nextItems ,
28
+ text : ""
29
+ } ) ;
30
+ }
29
31
} ,
30
32
31
33
render : function ( ) {
You can’t perform that action at this time.
0 commit comments