forked from benmvp/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailForm.js
64 lines (59 loc) · 1.6 KB
/
EmailForm.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
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, {PureComponent} from 'react';
import './EmailForm.css';
export default class EmailForm extends PureComponent {
state = {
from: '',
to: '[email protected]',
subject: '',
message: ''
};
_updateFormFieldState(name, e) {
this.setState({[name]: e.target.value});
}
render() {
let {from, to, subject, message} = this.state;
return (
<form className="email-form">
<fieldset>
<label htmlFor="from">From:</label>
<input
type="email"
id="from"
value={from}
placeholder="[email protected]"
onChange={this._updateFormFieldState.bind(this, 'from')}
/>
</fieldset>
<fieldset>
<label htmlFor="to">To:</label>
<input
type="email"
id="to"
value={to}
placeholder="[email protected]"
onChange={this._updateFormFieldState.bind(this, 'to')}
/>
</fieldset>
<fieldset>
<label htmlFor="subject">Subject:</label>
<input
type="text"
id="subject"
value={subject}
placeholder="Awesome React workshop!"
onChange={this._updateFormFieldState.bind(this, 'subject')}
/>
</fieldset>
<fieldset>
<label htmlFor="message">Message:</label>
<textarea
id="message"
value={message}
placeholder="[Insert message here]"
onChange={this._updateFormFieldState.bind(this, 'message')}
/>
</fieldset>
</form>
);
}
}