-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.js
51 lines (51 loc) · 1006 Bytes
/
contact.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import "./Contact.css"
class Contact extends React.Component {
constructor(props) {
super(props);
this.state = {
firstName: "",
lastName: "",
submitted: false,
};
}
handleFirstNameChange = (event) => {
this.setState({ firstName: event.target.value });
};
handleLastNameChange = (event) => {
this.setState({ lastName: event.target.value });
};
handleSubmit = (event) => {
event.preventDefault();
this.setState({ submitted: true });
};
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<label>First name:</label>
<input
type="text"
value={this.state.firstName}
onChange={this.handleFirstNameChange}
/>
<br />
<label>Last name:</label>
<input
type="text"
value={this.state.lastName}
onChange={this.handleLastNameChange}
/>
<br />
<button type="submit">Submit</button>
</form>
{this.state.submitted && (
<div>
<h4>Thank you {this.state.firstName} {this.state.lastName}</h4>
</div>
)}
</div>
);
}
}
export default Contact;