File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Expand file tree Collapse file tree 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({
3434
3535 handleSubmit : function ( e ) {
3636 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+ }
4143 } ,
4244
4345 render : function ( ) {
Original file line number Diff line number Diff line change @@ -25,10 +25,12 @@ var TodoApp3 = React.createClass({
2525
2626 handleSubmit : function ( e ) {
2727 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+ }
3234 } ,
3335
3436 render : function ( ) {
Original file line number Diff line number Diff line change @@ -19,13 +19,15 @@ var TodoApp1 = React.createClass({
1919
2020 handleSubmit : function ( e ) {
2121 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+ }
2931 } ,
3032
3133 render : function ( ) {
You can’t perform that action at this time.
0 commit comments