Skip to content

Instantly share code, notes, and snippets.

@rrgayhart
Last active May 15, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrgayhart/7207b26797a9a138509f4d3aad3fd4ff to your computer and use it in GitHub Desktop.
Save rrgayhart/7207b26797a9a138509f4d3aad3fd4ff to your computer and use it in GitHub Desktop.
code-snippit-redux-lesson.js
// 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