File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed
todos-with-undo/containers Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -347,15 +347,21 @@ let AddTodo = ({ dispatch }) => {
347347
348348 return (
349349 < div>
350- < input ref= {node => {
351- input = node
352- }} / >
353- < button onClick= {() => {
350+ < form onSubmit= {e => {
351+ e .preventDefault ()
352+ if (! input .value .trim ()) {
353+ return
354+ }
354355 dispatch (addTodo (input .value ))
355356 input .value = ' '
356357 }}>
357- Add Todo
358- < / button>
358+ < input ref= {node => {
359+ input = node
360+ }} / >
361+ < button type= " submit" >
362+ Add Todo
363+ < / button>
364+ < / form>
359365 < / div>
360366 )
361367}
Original file line number Diff line number Diff line change @@ -9,9 +9,10 @@ let AddTodo = ({ dispatch }) => {
99 < div >
1010 < form onSubmit = { e => {
1111 e . preventDefault ( )
12- if ( input . value . trim ( ) ) {
13- dispatch ( addTodo ( input . value ) )
12+ if ( ! input . value . trim ( ) ) {
13+ return
1414 }
15+ dispatch ( addTodo ( input . value ) )
1516 input . value = ''
1617 } } >
1718 < input ref = { node => {
Original file line number Diff line number Diff line change @@ -9,9 +9,10 @@ let AddTodo = ({ dispatch }) => {
99 < div >
1010 < form onSubmit = { e => {
1111 e . preventDefault ( )
12- if ( input . value . trim ( ) ) {
13- dispatch ( addTodo ( input . value ) )
12+ if ( ! input . value . trim ( ) ) {
13+ return
1414 }
15+ dispatch ( addTodo ( input . value ) )
1516 input . value = ''
1617 } } >
1718 < input ref = { node => {
You can’t perform that action at this time.
0 commit comments