Skip to content

Commit

Permalink
feat: Add the value of the name input to local state
Browse files Browse the repository at this point in the history
  • Loading branch information
dandenney committed Jul 23, 2017
1 parent 8fda67a commit 6888806
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/components/Exercises/NewExercise/index.js
Expand Up @@ -3,9 +3,39 @@ import { h, Component } from 'preact';
export default class NewExercise extends Component {
constructor() {
super();

this.state = {
name: ''
};

this.handleChange = this.handleChange.bind(this);
}

handleChange(e) {
this.setState({
[e.target.name]: e.target.value
});
}

render() {
return 'New Exercise Form';
const name = this.state;
return (
<section>
<h2>New Exercise</h2>

<form>
<div>
<label for="name">Name</label>
<input
type="text"
name="name"
onChange={this.handleChange}
placeholder="Chest Press"
value={this.state.name}
/>
</div>
</form>
</section>
);
}
}

0 comments on commit 6888806

Please sign in to comment.