Skip to content

Instantly share code, notes, and snippets.

@ManuelDeLeon
Created September 23, 2016 03:38
Show Gist options
  • Save ManuelDeLeon/50a350e08a8466c0ffe7a279f73afac2 to your computer and use it in GitHub Desktop.
Save ManuelDeLeon/50a350e08a8466c0ffe7a279f73afac2 to your computer and use it in GitHub Desktop.
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