-
-
Save rrgayhart/7207b26797a9a138509f4d3aad3fd4ff to your computer and use it in GitHub Desktop.
code-snippit-redux-lesson.js
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
// src/components/AddTodoForm.js | |
import React, { Component } from 'react' | |
class AddTodoForm extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { text: '' } | |
} | |
render() { | |
const { handleSubmit, todos } = this.props; | |
return ( | |
<section> | |
<form onSubmit={ (e) => { | |
e.preventDefault() | |
handleSubmit(this.state.text, todos.length) | |
}}> | |
<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// src/components/AddTodoForm.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment