Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active September 2, 2018 08:18
Show Gist options
  • Save agoiabel/08f8aaf7f12bb9dd2d25928b7b3579cf to your computer and use it in GitHub Desktop.
Save agoiabel/08f8aaf7f12bb9dd2d25928b7b3579cf to your computer and use it in GitHub Desktop.
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