-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04-ClassComponent(2).jsx
45 lines (41 loc) · 1.11 KB
/
04-ClassComponent(2).jsx
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
import React from 'react';
import Row from './Row';
export default class Greeting extends React.Component {
constructor(props) {
super(props);
this.state = {
name = "Mary",
surname = "Poppins"
}
this.handleNameChange = this.handleNameChange.bind(this);
this.handleSurnameChange = this.handleSurnameChange.bind(this);
}
handleNameChange(e) {
this.setState({
name: e.target.value
});
}
handleSurnameChange(e) {
this.setState({
surname: e.target.value
});
}
render(){
return (
<section>
<Row label="Name">
<input
value={this.state.name}
onChange={this.handleNameChange}
/>
</Row>
<Row label="Surname">
<input
value={this.state.surname}
onChange={this.handleSurnameChange}
/>
</Row>
</section>
)
}
}