Created
September 23, 2016 03:38
-
-
Save ManuelDeLeon/50a350e08a8466c0ffe7a279f73afac2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connect } from 'react-redux' | |
import { addTodo } from '../actions' | |
let AddTodo = ({ dispatch }) => { | |
let input | |
return ( | |
<div> | |
<form onSubmit={e => { | |
e.preventDefault() | |
if (!input.value.trim()) { | |
return | |
} | |
dispatch(addTodo(input.value)) | |
input.value = '' | |
}}> | |
<input ref={node => { | |
input = node | |
}} /> | |
<button type="submit"> | |
Add Todo | |
</button> | |
</form> | |
</div> | |
) | |
} | |
AddTodo = connect()(AddTodo) | |
export default AddTodo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment