Last active
May 22, 2017 22:27
-
-
Save Louiefigz/98fa90880bc6a9ef315668474dbd473c 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"; | |
export default class UserInput extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
task: '' | |
}; | |
} | |
handleChange(event) { | |
this.setState({ | |
task: event.target.value | |
}); | |
} | |
handleOnSubmit(event) { | |
event.preventDefault(); | |
this.props.store.dispatch({ | |
type: "ADD_TASK", | |
task: this.state.task | |
}) | |
} | |
render() { | |
return( | |
<form onSubmit={(event) => this.handleOnSubmit(event)}> | |
<p> | |
<input | |
type="text" | |
onChange={(event) => this.handleChange(event)} | |
placeholder="enter name"/> | |
</p> | |
<input type="submit" /> | |
</form> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment