Skip to content

Commit 8ec0e4a

Browse files
authored
Removed Array.from() usage (#12546)
1 parent d328e36 commit 8ec0e4a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

packages/react-reconciler/src/ReactStrictModeWarnings.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ if (__DEV__) {
4646
const didWarnAboutDeprecatedLifecycles = new Set();
4747
const didWarnAboutUnsafeLifecycles = new Set();
4848

49+
const setToSortedString = set => {
50+
const array = [];
51+
set.forEach(value => {
52+
array.push(value);
53+
});
54+
return array.sort().join(', ');
55+
};
56+
4957
ReactStrictModeWarnings.discardPendingWarnings = () => {
5058
pendingComponentWillMountWarnings = [];
5159
pendingComponentWillReceivePropsWarnings = [];
@@ -69,9 +77,7 @@ if (__DEV__) {
6977

7078
const formatted = lifecycle.replace('UNSAFE_', '');
7179
const suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
72-
const sortedComponentNames = Array.from(componentNames)
73-
.sort()
74-
.join(', ');
80+
const sortedComponentNames = setToSortedString(componentNames);
7581

7682
lifecyclesWarningMesages.push(
7783
`${formatted}: Please update the following components to use ` +
@@ -123,9 +129,7 @@ if (__DEV__) {
123129
didWarnAboutDeprecatedLifecycles.add(fiber.type);
124130
});
125131

126-
const sortedNames = Array.from(uniqueNames)
127-
.sort()
128-
.join(', ');
132+
const sortedNames = setToSortedString(uniqueNames);
129133

130134
lowPriorityWarning(
131135
false,
@@ -148,9 +152,7 @@ if (__DEV__) {
148152
didWarnAboutDeprecatedLifecycles.add(fiber.type);
149153
});
150154

151-
const sortedNames = Array.from(uniqueNames)
152-
.sort()
153-
.join(', ');
155+
const sortedNames = setToSortedString(uniqueNames);
154156

155157
lowPriorityWarning(
156158
false,
@@ -172,9 +174,7 @@ if (__DEV__) {
172174
didWarnAboutDeprecatedLifecycles.add(fiber.type);
173175
});
174176

175-
const sortedNames = Array.from(uniqueNames)
176-
.sort()
177-
.join(', ');
177+
const sortedNames = setToSortedString(uniqueNames);
178178

179179
lowPriorityWarning(
180180
false,

0 commit comments

Comments
 (0)