Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react'
- import { connect } from 'react-redux'
- import { addTodo, addTodoAsync } from '../actions'
- let AddTodo = ({ dispatch }) => {
- let input
- return (
- <div>
- <form onSubmit={e => {
- e.preventDefault()
- if (!input.value.trim()) {
- return
- }
- dispatch(addTodoAsync(input.value)).then(() => {
- console.log('done!');
- })
- input.value = ''
- }}>
- <input ref={node => {
- input = node
- }} />
- <button type="submit">
- Add Todo
- </button>
- </form>
- </div>
- )
- }
- AddTodo = connect()(AddTodo)
- export default AddTodo
Add Comment
Please, Sign In to add comment