Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Form extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- contact: {}
- };
- }
- handleChange = e => {
- const target = e.target;
- const name = target.name;
- const value = target.value;
- this.setState({
- [name]: value
- });
- }
- render() {
- return (
- <form addContact={() => this.props.addContact(this.state.contact)}>
- <input value={this.state.name} type="text" name="name" onChange={this.handleChange} />
- <input value={this.state.tel} type="text" name="tel" onChange={this.handleChange} />
- <button className="submit">OK</button>
- </form>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement