Skip to content

Commit

Permalink
Removed Array.from() usage (facebook#12546)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn authored and rhagigi committed Apr 19, 2018
1 parent 11013fe commit 97181b4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/react-reconciler/src/ReactStrictModeWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ if (__DEV__) {
const didWarnAboutDeprecatedLifecycles = new Set();
const didWarnAboutUnsafeLifecycles = new Set();

const setToSortedString = set => {
const array = [];
set.forEach(value => {
array.push(value);
});
return array.sort().join(', ');
};

ReactStrictModeWarnings.discardPendingWarnings = () => {
pendingComponentWillMountWarnings = [];
pendingComponentWillReceivePropsWarnings = [];
Expand All @@ -69,9 +77,7 @@ if (__DEV__) {

const formatted = lifecycle.replace('UNSAFE_', '');
const suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
const sortedComponentNames = Array.from(componentNames)
.sort()
.join(', ');
const sortedComponentNames = setToSortedString(componentNames);

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

const sortedNames = Array.from(uniqueNames)
.sort()
.join(', ');
const sortedNames = setToSortedString(uniqueNames);

lowPriorityWarning(
false,
Expand All @@ -148,9 +152,7 @@ if (__DEV__) {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});

const sortedNames = Array.from(uniqueNames)
.sort()
.join(', ');
const sortedNames = setToSortedString(uniqueNames);

lowPriorityWarning(
false,
Expand All @@ -172,9 +174,7 @@ if (__DEV__) {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});

const sortedNames = Array.from(uniqueNames)
.sort()
.join(', ');
const sortedNames = setToSortedString(uniqueNames);

lowPriorityWarning(
false,
Expand Down

0 comments on commit 97181b4

Please sign in to comment.