@@ -39,6 +39,10 @@ describe('ReactClassComponentPropResolution', () => {
39
39
}
40
40
41
41
class Component extends React . Component {
42
+ constructor ( props ) {
43
+ super ( props ) ;
44
+ Scheduler . log ( 'constructor: ' + getPropKeys ( props ) ) ;
45
+ }
42
46
shouldComponentUpdate ( props ) {
43
47
Scheduler . log (
44
48
'shouldComponentUpdate (prev props): ' + getPropKeys ( this . props ) ,
@@ -59,6 +63,28 @@ describe('ReactClassComponentPropResolution', () => {
59
63
Scheduler . log ( 'componentDidMount: ' + getPropKeys ( this . props ) ) ;
60
64
return true ;
61
65
}
66
+ UNSAFE_componentWillMount ( ) {
67
+ Scheduler . log ( 'componentWillMount: ' + getPropKeys ( this . props ) ) ;
68
+ }
69
+ UNSAFE_componentWillReceiveProps ( nextProps ) {
70
+ Scheduler . log (
71
+ 'componentWillReceiveProps (prev props): ' + getPropKeys ( this . props ) ,
72
+ ) ;
73
+ Scheduler . log (
74
+ 'componentWillReceiveProps (next props): ' + getPropKeys ( nextProps ) ,
75
+ ) ;
76
+ }
77
+ UNSAFE_componentWillUpdate ( nextProps ) {
78
+ Scheduler . log (
79
+ 'componentWillUpdate (prev props): ' + getPropKeys ( this . props ) ,
80
+ ) ;
81
+ Scheduler . log (
82
+ 'componentWillUpdate (next props): ' + getPropKeys ( nextProps ) ,
83
+ ) ;
84
+ }
85
+ componentWillUnmount ( ) {
86
+ Scheduler . log ( 'componentWillUnmount: ' + getPropKeys ( this . props ) ) ;
87
+ }
62
88
render ( ) {
63
89
return < Text text = { 'render: ' + getPropKeys ( this . props ) } /> ;
64
90
}
@@ -75,18 +101,33 @@ describe('ReactClassComponentPropResolution', () => {
75
101
await act ( async ( ) => {
76
102
root . render ( < Component text = "Yay" ref = { ref } /> ) ;
77
103
} ) ;
78
- assertLog ( [ 'render: text, default' , 'componentDidMount: text, default' ] ) ;
104
+ assertLog ( [
105
+ 'constructor: text, default' ,
106
+ 'componentWillMount: text, default' ,
107
+ 'render: text, default' ,
108
+ 'componentDidMount: text, default' ,
109
+ ] ) ;
79
110
80
111
// Update
81
112
await act ( async ( ) => {
82
113
root . render ( < Component text = "Yay (again)" ref = { ref } /> ) ;
83
114
} ) ;
84
115
assertLog ( [
116
+ 'componentWillReceiveProps (prev props): text, default' ,
117
+ 'componentWillReceiveProps (next props): text, default' ,
85
118
'shouldComponentUpdate (prev props): text, default' ,
86
119
'shouldComponentUpdate (next props): text, default' ,
120
+ 'componentWillUpdate (prev props): text, default' ,
121
+ 'componentWillUpdate (next props): text, default' ,
87
122
'render: text, default' ,
88
123
'componentDidUpdate (prev props): text, default' ,
89
124
'componentDidUpdate (next props): text, default' ,
90
125
] ) ;
126
+
127
+ // Unmount
128
+ await act ( async ( ) => {
129
+ root . render ( null ) ;
130
+ } ) ;
131
+ assertLog ( [ 'componentWillUnmount: text, default' ] ) ;
91
132
} ) ;
92
133
} ) ;
0 commit comments