Guest User

Untitled

a guest
Oct 16th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import { addTodo } from '../actions'
  4.  
  5. let AddTodo = ({ dispatch }) => {
  6. let input
  7.  
  8. return (
  9. <div>
  10. <form
  11. onSubmit={e => {
  12. e.preventDefault()
  13. if (!input.value.trim()) {
  14. return
  15. }
  16. dispatch(addTodo(input.value))
  17. input.value = ''
  18. }}
  19. >
  20. <input
  21. ref={node => {
  22. input = node
  23. }}
  24. />
  25. <button type="submit">
  26. Add Todo
  27. </button>
  28. </form>
  29. </div>
  30. )
  31. }
  32. AddTodo = connect()(AddTodo)
  33.  
  34. export default AddTodo
Add Comment
Please, Sign In to add comment