File tree Expand file tree Collapse file tree 3 files changed +36
-18
lines changed
todos-with-undo/containers Expand file tree Collapse file tree 3 files changed +36
-18
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 @@ -7,15 +7,21 @@ let AddTodo = ({ dispatch }) => {
77
88 return (
99 < div >
10- < input ref = { node => {
11- input = node
12- } } />
13- < button onClick = { ( ) => {
10+ < form onSubmit = { e => {
11+ e . preventDefault ( )
12+ if ( ! input . value . trim ( ) ) {
13+ return
14+ }
1415 dispatch ( addTodo ( input . value ) )
1516 input . value = ''
1617 } } >
17- Add Todo
18- </ button >
18+ < input ref = { node => {
19+ input = node
20+ } } />
21+ < button type = "submit" >
22+ Add Todo
23+ </ button >
24+ </ form >
1925 </ div >
2026 )
2127}
Original file line number Diff line number Diff line change @@ -7,15 +7,21 @@ let AddTodo = ({ dispatch }) => {
77
88 return (
99 < div >
10- < input ref = { node => {
11- input = node
12- } } />
13- < button onClick = { ( ) => {
10+ < form onSubmit = { e => {
11+ e . preventDefault ( )
12+ if ( ! input . value . trim ( ) ) {
13+ return
14+ }
1415 dispatch ( addTodo ( input . value ) )
1516 input . value = ''
1617 } } >
17- Add Todo
18- </ button >
18+ < input ref = { node => {
19+ input = node
20+ } } />
21+ < button type = "submit" >
22+ Add Todo
23+ </ button >
24+ </ form >
1925 </ div >
2026 )
2127}
You can’t perform that action at this time.
0 commit comments