Skip to content

Commit

Permalink
2 way binding with inputs on card
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxnelson997 committed May 17, 2018
1 parent 892cf7e commit 7a05701
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ class Card extends Component {
color: 'BLUE',
pluralNoun: ''
}
}

handleInputChange() {
this.setState({ color: 'red' })
this.handleInputChange = this.handleInputChange.bind(this);
}

handleInputChange(event) {
this.setState({ color: event.target.value })
}

render() {

return (
<div className="card">
<h1>{this.state.color}</h1>
<input/>
<input value={this.state.color} onChange={(event) => this.handleInputChange(event)}/>
</div>
)

Expand Down

0 comments on commit 7a05701

Please sign in to comment.