@samitouri / QOS-React-2 / commits / 8ec0e4a99d

Removed Array.from() usage (#12546)

Brian Vaughn committed Apr 4, 2018 at 13:54 UTC 8ec0e4a99df76c0ff1779cac4f2eaaaf35a6b5bb
1 file changed +12 -12
packages/react-reconciler/src/ReactStrictModeWarnings.js
+12 -12
@@ -46,6 +46,14 @@ if (__DEV__) {
46 const didWarnAboutDeprecatedLifecycles = new Set();
47 const didWarnAboutUnsafeLifecycles = new Set();
48
49 + const setToSortedString = set => {
50 + const array = [];
51 + set.forEach(value => {
52 + array.push(value);
53 + });
54 + return array.sort().join(', ');
55 + };
56 +
57 ReactStrictModeWarnings.discardPendingWarnings = () => {
58 pendingComponentWillMountWarnings = [];
59 pendingComponentWillReceivePropsWarnings = [];
@@ -69,9 +77,7 @@ if (__DEV__) {
77
78 const formatted = lifecycle.replace('UNSAFE_', '');
79 const suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
72 - const sortedComponentNames = Array.from(componentNames)
73 - .sort()
74 - .join(', ');
80 + const sortedComponentNames = setToSortedString(componentNames);
81
82 lifecyclesWarningMesages.push(
83 `${formatted}: Please update the following components to use ` +
@@ -123,9 +129,7 @@ if (__DEV__) {
129 didWarnAboutDeprecatedLifecycles.add(fiber.type);
130 });
131
126 - const sortedNames = Array.from(uniqueNames)
127 - .sort()
128 - .join(', ');
132 + const sortedNames = setToSortedString(uniqueNames);
133
134 lowPriorityWarning(
135 false,
@@ -148,9 +152,7 @@ if (__DEV__) {
152 didWarnAboutDeprecatedLifecycles.add(fiber.type);
153 });
154
151 - const sortedNames = Array.from(uniqueNames)
152 - .sort()
153 - .join(', ');
155 + const sortedNames = setToSortedString(uniqueNames);
156
157 lowPriorityWarning(
158 false,
@@ -172,9 +174,7 @@ if (__DEV__) {
174 didWarnAboutDeprecatedLifecycles.add(fiber.type);
175 });
176
175 - const sortedNames = Array.from(uniqueNames)
176 - .sort()
177 - .join(', ');
177 + const sortedNames = setToSortedString(uniqueNames);
178
179 lowPriorityWarning(
180 false,