@@ -46,6 +46,14 @@ if (__DEV__) {
46
46
const didWarnAboutDeprecatedLifecycles = new Set ( ) ;
47
47
const didWarnAboutUnsafeLifecycles = new Set ( ) ;
48
48
49
+ const setToSortedString = set => {
50
+ const array = [ ] ;
51
+ set . forEach ( value => {
52
+ array . push ( value ) ;
53
+ } ) ;
54
+ return array . sort ( ) . join ( ', ' ) ;
55
+ } ;
56
+
49
57
ReactStrictModeWarnings . discardPendingWarnings = ( ) => {
50
58
pendingComponentWillMountWarnings = [ ] ;
51
59
pendingComponentWillReceivePropsWarnings = [ ] ;
@@ -69,9 +77,7 @@ if (__DEV__) {
69
77
70
78
const formatted = lifecycle . replace ( 'UNSAFE_' , '' ) ;
71
79
const suggestion = LIFECYCLE_SUGGESTIONS [ lifecycle ] ;
72
- const sortedComponentNames = Array . from ( componentNames )
73
- . sort ( )
74
- . join ( ', ' ) ;
80
+ const sortedComponentNames = setToSortedString ( componentNames ) ;
75
81
76
82
lifecyclesWarningMesages . push (
77
83
`${ formatted } : Please update the following components to use ` +
@@ -123,9 +129,7 @@ if (__DEV__) {
123
129
didWarnAboutDeprecatedLifecycles . add ( fiber . type ) ;
124
130
} ) ;
125
131
126
- const sortedNames = Array . from ( uniqueNames )
127
- . sort ( )
128
- . join ( ', ' ) ;
132
+ const sortedNames = setToSortedString ( uniqueNames ) ;
129
133
130
134
lowPriorityWarning (
131
135
false ,
@@ -148,9 +152,7 @@ if (__DEV__) {
148
152
didWarnAboutDeprecatedLifecycles . add ( fiber . type ) ;
149
153
} ) ;
150
154
151
- const sortedNames = Array . from ( uniqueNames )
152
- . sort ( )
153
- . join ( ', ' ) ;
155
+ const sortedNames = setToSortedString ( uniqueNames ) ;
154
156
155
157
lowPriorityWarning (
156
158
false ,
@@ -172,9 +174,7 @@ if (__DEV__) {
172
174
didWarnAboutDeprecatedLifecycles . add ( fiber . type ) ;
173
175
} ) ;
174
176
175
- const sortedNames = Array . from ( uniqueNames )
176
- . sort ( )
177
- . join ( ', ' ) ;
177
+ const sortedNames = setToSortedString ( uniqueNames ) ;
178
178
179
179
lowPriorityWarning (
180
180
false ,
0 commit comments