-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersons.js
More file actions
63 lines (52 loc) · 1.61 KB
/
Persons.js
File metadata and controls
63 lines (52 loc) · 1.61 KB
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
import React, { PureComponent } from 'react';
import Person from './Person/Person';
class Persons extends PureComponent {
// static getDerivedStateFromProps(props, state) {
// console.log('[Persons.js] getDerivedStateFromProps');
// return state;
// }
// componentWillReceiveProps(props) {
// console.log('[Persons.js] componentWillReceiveProps', props);
// }
// shouldComponentUpdate(nextProps, nextState) {
// console.log('[Persons.js] shouldComponentUpdate');
// if (
// nextProps.persons !== this.props.persons ||
// nextProps.changed !== this.props.changed ||
// nextProps.clicked !== this.props.clicked
// ) {
// return true;
// } else {
// return false;
// }
// // return true;
// }
getSnapshotBeforeUpdate(prevProps, prevState) {
console.log('[Persons.js] getSnapshotBeforeUpdate');
return { message: 'Snapshot!' };
}
// componentWillUpdate() {
// }
componentDidUpdate(prevProps, prevState, snapshot) {
console.log('[Persons.js] componentDidUpdate');
console.log(snapshot);
}
componentWillUnmount() {
console.log('[Persons.js] componentWillUnmount');
}
render() {
console.log('[Persons.js] rendering...');
return this.props.persons.map((person, index) => {
return (
<Person
click={() => this.props.clicked(index)}
name={person.name}
age={person.age}
key={person.id}
changed={event => this.props.changed(event, person.id)}
/>
);
});
}
}
export default Persons;