Created
October 24, 2018 13:48
-
-
Save wvmitchell/af56336cb50e867b44a3ba91c873b205 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { Component } from 'react' | |
| import { connect } from 'react-redux' | |
| import uuid from 'uuid/v1' | |
| class AddTodoForm extends Component { | |
| constructor(props) { | |
| super(props) | |
| this.state = { text: '' } | |
| } | |
| render() { | |
| const { handleSubmit, todos } = this.props; | |
| return ( | |
| <section> | |
| <h2>Things to do: {todos.length}</h2> | |
| <form onSubmit={ (e) => { | |
| e.preventDefault() | |
| handleSubmit(this.state.text, uuid()) | |
| }}> | |
| <input value={this.state.text} | |
| placeholder="Add A Todo" | |
| onChange={(e) => this.setState({ text: e.target.value} )} /> | |
| <button>Add Todo</button> | |
| </form> | |
| </section> | |
| ) | |
| } | |
| } | |
| export default AddTodoForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment