Last active
September 2, 2018 08:18
-
-
Save agoiabel/08f8aaf7f12bb9dd2d25928b7b3579cf to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react'; | |
import TextInput from './TextInput'; | |
class FormComponent extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
formControls: { | |
name: { | |
value: '', | |
placeholder: 'What is your name' | |
} | |
} | |
} | |
} | |
changeHandler = event => { | |
const name = event.target.name; | |
const value = event.target.value; | |
this.setState({ | |
formControls: { | |
[name]: value | |
} | |
}); | |
} | |
render() { | |
return ( | |
<TextInput name="name" | |
placeholder={this.state.formControls.name.placeholder} | |
value={this.state.formControls.name.value} | |
onChange={this.changeHandler} | |
/> | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment