@samitouri / QOS-React-2 / commits / b4f119cdf1

Revert "Remove redundant initial of isArray (#21163)"

This reverts commit b130a0f5cd4f29a1c3147f66e10914c42847678a.

Sebastian Markbage committed Apr 1, 2021 at 15:19 UTC b4f119cdf1defe2437e00022f670c6ef818cd43f
28 files changed +77 -105
packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
+4 -6
@@ -145,8 +145,6 @@ export default {
145 componentScope = currentScope;
146 }
147
148 - const isArray = Array.isArray;
149 -
148 // Next we'll define a few helpers that helps us
149 // tell if some values don't have to be declared as deps.
150
@@ -159,7 +157,7 @@ export default {
157 // ^^^ true for this reference
158 // False for everything else.
159 function isStableKnownHookValue(resolved) {
162 - if (!isArray(resolved.defs)) {
160 + if (!Array.isArray(resolved.defs)) {
161 return false;
162 }
163 const def = resolved.defs[0];
@@ -228,7 +226,7 @@ export default {
226 if (
227 id.type === 'ArrayPattern' &&
228 id.elements.length === 2 &&
231 - isArray(resolved.identifiers)
229 + Array.isArray(resolved.identifiers)
230 ) {
231 // Is second tuple value the same reference we're checking?
232 if (id.elements[1] === resolved.identifiers[0]) {
@@ -257,7 +255,7 @@ export default {
255 } else if (name === 'useTransition') {
256 if (
257 id.type === 'ArrayPattern' &&
260 - isArray(resolved.identifiers)
258 + Array.isArray(resolved.identifiers)
259 ) {
260 // Is first tuple value the same reference we're checking?
261 if (id.elements[0] === resolved.identifiers[0]) {
@@ -272,7 +270,7 @@ export default {
270
271 // Some are just functions that don't reference anything dynamic.
272 function isFunctionWithoutCapturedValues(resolved) {
275 - if (!isArray(resolved.defs)) {
273 + if (!Array.isArray(resolved.defs)) {
274 return false;
275 }
276 const def = resolved.defs[0];
packages/jest-react/src/JestReact.js
+1 -2
@@ -8,7 +8,6 @@
8 import {REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols';
9
10 import invariant from 'shared/invariant';
11 -import isArray from 'shared/isArray';
11
12 function captureAssertion(fn) {
13 // Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
@@ -43,7 +42,7 @@ export function unstable_toMatchRenderedOutput(root, expectedJSX) {
42 let actualJSX;
43 if (actualJSON === null || typeof actualJSON === 'string') {
44 actualJSX = actualJSON;
46 - } else if (isArray(actualJSON)) {
45 + } else if (Array.isArray(actualJSON)) {
46 if (actualJSON.length === 0) {
47 actualJSX = null;
48 } else if (actualJSON.length === 1) {
packages/react-devtools-shared/src/backend/renderer.js
+1 -2
@@ -105,7 +105,6 @@ import type {
105 ElementType,
106 } from 'react-devtools-shared/src/types';
107 import is from 'shared/objectIs';
108 -import isArray from 'shared/isArray';
108
109 type getDisplayNameForFiberType = (fiber: Fiber) => string | null;
110 type getTypeSymbolType = (type: any) => Symbol | number;
@@ -1138,7 +1137,7 @@ export function attach(
1137 memoizedState.hasOwnProperty('create') &&
1138 memoizedState.hasOwnProperty('destroy') &&
1139 memoizedState.hasOwnProperty('deps') &&
1141 - (memoizedState.deps === null || isArray(memoizedState.deps)) &&
1140 + (memoizedState.deps === null || Array.isArray(memoizedState.deps)) &&
1141 memoizedState.hasOwnProperty('next')
1142 );
1143 }
packages/react-devtools-shared/src/backend/utils.js
+5 -6
@@ -9,7 +9,6 @@
9
10 import {copy} from 'clipboard-js';
11 import {dehydrate} from '../hydration';
12 -import isArray from 'shared/isArray';
12
13 import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Components/types';
14
@@ -62,9 +61,9 @@ export function copyWithDelete(
61 index: number = 0,
62 ): Object | Array<any> {
63 const key = path[index];
65 - const updated = isArray(obj) ? obj.slice() : {...obj};
64 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
65 if (index + 1 === path.length) {
67 - if (isArray(updated)) {
66 + if (Array.isArray(updated)) {
67 updated.splice(((key: any): number), 1);
68 } else {
69 delete updated[key];
@@ -85,12 +84,12 @@ export function copyWithRename(
84 index: number = 0,
85 ): Object | Array<any> {
86 const oldKey = oldPath[index];
88 - const updated = isArray(obj) ? obj.slice() : {...obj};
87 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
88 if (index + 1 === oldPath.length) {
89 const newKey = newPath[index];
90 // $FlowFixMe number or string is fine here
91 updated[newKey] = updated[oldKey];
93 - if (isArray(updated)) {
92 + if (Array.isArray(updated)) {
93 updated.splice(((oldKey: any): number), 1);
94 } else {
95 delete updated[oldKey];
@@ -112,7 +111,7 @@ export function copyWithSet(
111 return value;
112 }
113 const key = path[index];
115 - const updated = isArray(obj) ? obj.slice() : {...obj};
114 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
115 // $FlowFixMe number or string is fine here
116 updated[key] = copyWithSet(obj[key], path, value, index + 1);
117 return updated;
packages/react-dom/src/client/ReactDOMSelect.js
+3 -4
@@ -12,7 +12,6 @@ import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCur
12
13 import {checkControlledValueProps} from '../shared/ReactControlledValuePropTypes';
14 import {getToStringValue, toString} from './ToStringValue';
15 -import isArray from 'shared/isArray';
15
16 let didWarnValueDefaultValue;
17
@@ -46,15 +45,15 @@ function checkSelectPropTypes(props) {
45 if (props[propName] == null) {
46 continue;
47 }
49 - const propNameIsArray = isArray(props[propName]);
50 - if (props.multiple && !propNameIsArray) {
48 + const isArray = Array.isArray(props[propName]);
49 + if (props.multiple && !isArray) {
50 console.error(
51 'The `%s` prop supplied to <select> must be an array if ' +
52 '`multiple` is true.%s',
53 propName,
54 getDeclarationErrorAddendum(),
55 );
57 - } else if (!props.multiple && propNameIsArray) {
56 + } else if (!props.multiple && isArray) {
57 console.error(
58 'The `%s` prop supplied to <select> must be a scalar ' +
59 'value if `multiple` is false.%s',
packages/react-dom/src/client/ReactDOMTextarea.js
+2 -2
@@ -8,12 +8,12 @@
8 */
9
10 import invariant from 'shared/invariant';
11 -import isArray from 'shared/isArray';
11
12 import {checkControlledValueProps} from '../shared/ReactControlledValuePropTypes';
13 import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCurrentFiber';
14 import {getToStringValue, toString} from './ToStringValue';
15 import type {ToStringValue} from './ToStringValue';
16 +
17 import {disableTextareaChildren} from 'shared/ReactFeatureFlags';
18
19 let didWarnValDefaultVal = false;
@@ -100,7 +100,7 @@ export function initWrapperState(element: Element, props: Object) {
100 defaultValue == null,
101 'If you supply `defaultValue` on a <textarea>, do not pass children.',
102 );
103 - if (isArray(children)) {
103 + if (Array.isArray(children)) {
104 invariant(
105 children.length <= 1,
106 '<textarea> can only have at most one child.',
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+2 -1
@@ -46,7 +46,8 @@ import hyphenateStyleName from '../shared/hyphenateStyleName';
46 import invariant from 'shared/invariant';
47 import hasOwnProperty from 'shared/hasOwnProperty';
48 import sanitizeURL from '../shared/sanitizeURL';
49 -import isArray from 'shared/isArray';
49 +
50 +const isArray = Array.isArray;
51
52 // Per response, global state that is not contextual to the rendering subtree.
53 export type ResponseState = {
packages/react-dom/src/server/ReactPartialRenderer.js
+5 -6
@@ -14,7 +14,6 @@ import type {ReactProvider, ReactContext} from 'shared/ReactTypes';
14
15 import * as React from 'react';
16 import invariant from 'shared/invariant';
17 -import isArray from 'shared/isArray';
17 import getComponentNameFromType from 'shared/getComponentNameFromType';
18 import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
19 import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -1439,7 +1438,7 @@ class ReactDOMServerRenderer {
1438 defaultValue == null,
1439 'If you supply `defaultValue` on a <textarea>, do not pass children.',
1440 );
1442 - if (isArray(textareaChildren)) {
1441 + if (Array.isArray(textareaChildren)) {
1442 invariant(
1443 textareaChildren.length <= 1,
1444 '<textarea> can only have at most one child.',
@@ -1468,14 +1467,14 @@ class ReactDOMServerRenderer {
1467 if (props[propName] == null) {
1468 continue;
1469 }
1471 - const propNameIsArray = isArray(props[propName]);
1472 - if (props.multiple && !propNameIsArray) {
1470 + const isArray = Array.isArray(props[propName]);
1471 + if (props.multiple && !isArray) {
1472 console.error(
1473 'The `%s` prop supplied to <select> must be an array if ' +
1474 '`multiple` is true.',
1475 propName,
1476 );
1478 - } else if (!props.multiple && propNameIsArray) {
1477 + } else if (!props.multiple && isArray) {
1478 console.error(
1479 'The `%s` prop supplied to <select> must be a scalar ' +
1480 'value if `multiple` is false.',
@@ -1516,7 +1515,7 @@ class ReactDOMServerRenderer {
1515 value = optionChildren;
1516 }
1517 selected = false;
1519 - if (isArray(selectValue)) {
1518 + if (Array.isArray(selectValue)) {
1519 // multiple
1520 for (let j = 0; j < selectValue.length; j++) {
1521 if ('' + selectValue[j] === value) {
packages/react-dom/src/test-utils/ReactTestUtils.js
+3 -4
@@ -24,7 +24,6 @@ import {
24 rethrowCaughtError,
25 invokeGuardedCallbackAndCatchFirstError,
26 } from 'shared/ReactErrorUtils';
27 -import isArray from 'shared/isArray';
27
28 // Keep in sync with ReactDOM.js, and ReactTestUtilsAct.js:
29 const EventInternals =
@@ -98,7 +97,7 @@ function validateClassInstance(inst, methodName) {
97 }
98 let received;
99 const stringified = '' + inst;
101 - if (isArray(inst)) {
100 + if (Array.isArray(inst)) {
101 received = 'an array';
102 } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
103 received = 'a DOM node';
@@ -198,7 +197,7 @@ function scryRenderedDOMComponentsWithClass(root, classNames) {
197 }
198 const classList = className.split(/\s+/);
199
201 - if (!isArray(classNames)) {
200 + if (!Array.isArray(classNames)) {
201 invariant(
202 classNames !== undefined,
203 'TestUtils.scryRenderedDOMComponentsWithClass expects a ' +
@@ -366,7 +365,7 @@ function executeDispatch(event, listener, inst) {
365 function executeDispatchesInOrder(event) {
366 const dispatchListeners = event._dispatchListeners;
367 const dispatchInstances = event._dispatchInstances;
369 - if (isArray(dispatchListeners)) {
368 + if (Array.isArray(dispatchListeners)) {
369 for (let i = 0; i < dispatchListeners.length; i++) {
370 if (event.isPropagationStopped()) {
371 break;
packages/react-native-renderer/src/ReactNativeAttributePayload.js
+6 -7
@@ -12,7 +12,6 @@ import {
12 deepDiffer,
13 flattenStyle,
14 } from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
15 -import isArray from 'shared/isArray';
15
16 import type {AttributeConfiguration} from './ReactNativeTypes';
17
@@ -52,7 +51,7 @@ function restoreDeletedValuesInNestedArray(
51 node: NestedNode,
52 validAttributes: AttributeConfiguration,
53 ) {
55 - if (isArray(node)) {
54 + if (Array.isArray(node)) {
55 let i = node.length;
56 while (i-- && removedKeyCount > 0) {
57 restoreDeletedValuesInNestedArray(
@@ -164,12 +163,12 @@ function diffNestedProperty(
163 return updatePayload;
164 }
165
167 - if (!isArray(prevProp) && !isArray(nextProp)) {
166 + if (!Array.isArray(prevProp) && !Array.isArray(nextProp)) {
167 // Both are leaves, we can diff the leaves.
168 return diffProperties(updatePayload, prevProp, nextProp, validAttributes);
169 }
170
172 - if (isArray(prevProp) && isArray(nextProp)) {
171 + if (Array.isArray(prevProp) && Array.isArray(nextProp)) {
172 // Both are arrays, we can diff the arrays.
173 return diffNestedArrayProperty(
174 updatePayload,
@@ -179,7 +178,7 @@ function diffNestedProperty(
178 );
179 }
180
182 - if (isArray(prevProp)) {
181 + if (Array.isArray(prevProp)) {
182 return diffProperties(
183 updatePayload,
184 // $FlowFixMe - We know that this is always an object when the input is.
@@ -213,7 +212,7 @@ function addNestedProperty(
212 return updatePayload;
213 }
214
216 - if (!isArray(nextProp)) {
215 + if (!Array.isArray(nextProp)) {
216 // Add each property of the leaf.
217 return addProperties(updatePayload, nextProp, validAttributes);
218 }
@@ -243,7 +242,7 @@ function clearNestedProperty(
242 return updatePayload;
243 }
244
246 - if (!isArray(prevProp)) {
245 + if (!Array.isArray(prevProp)) {
246 // Add each property of the leaf.
247 return clearProperties(updatePayload, prevProp, validAttributes);
248 }
packages/react-native-renderer/src/legacy-events/EventPluginUtils.js
+5 -6
@@ -7,7 +7,6 @@
7
8 import {invokeGuardedCallbackAndCatchFirstError} from 'shared/ReactErrorUtils';
9 import invariant from 'shared/invariant';
10 -import isArray from 'shared/isArray';
10
11 export let getFiberCurrentPropsFromNode = null;
12 export let getInstanceFromNode = null;
@@ -37,14 +36,14 @@ if (__DEV__) {
36 const dispatchListeners = event._dispatchListeners;
37 const dispatchInstances = event._dispatchInstances;
38
40 - const listenersIsArr = isArray(dispatchListeners);
39 + const listenersIsArr = Array.isArray(dispatchListeners);
40 const listenersLen = listenersIsArr
41 ? dispatchListeners.length
42 : dispatchListeners
43 ? 1
44 : 0;
45
47 - const instancesIsArr = isArray(dispatchInstances);
46 + const instancesIsArr = Array.isArray(dispatchInstances);
47 const instancesLen = instancesIsArr
48 ? dispatchInstances.length
49 : dispatchInstances
@@ -79,7 +78,7 @@ export function executeDispatchesInOrder(event) {
78 if (__DEV__) {
79 validateEventDispatches(event);
80 }
82 - if (isArray(dispatchListeners)) {
81 + if (Array.isArray(dispatchListeners)) {
82 for (let i = 0; i < dispatchListeners.length; i++) {
83 if (event.isPropagationStopped()) {
84 break;
@@ -107,7 +106,7 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
106 if (__DEV__) {
107 validateEventDispatches(event);
108 }
110 - if (isArray(dispatchListeners)) {
109 + if (Array.isArray(dispatchListeners)) {
110 for (let i = 0; i < dispatchListeners.length; i++) {
111 if (event.isPropagationStopped()) {
112 break;
@@ -151,7 +150,7 @@ export function executeDirectDispatch(event) {
150 const dispatchListener = event._dispatchListeners;
151 const dispatchInstance = event._dispatchInstances;
152 invariant(
154 - !isArray(dispatchListener),
153 + !Array.isArray(dispatchListener),
154 'executeDirectDispatch(...): Invalid `event`.',
155 );
156 event.currentTarget = dispatchListener
packages/react-native-renderer/src/legacy-events/accumulate.js
+2 -3
@@ -8,7 +8,6 @@
8 */
9
10 import invariant from 'shared/invariant';
11 -import isArray from 'shared/isArray';
11
12 /**
13 * Accumulates items that must not be null or undefined.
@@ -32,11 +31,11 @@ function accumulate<T>(
31
32 // Both are not empty. Warning: Never call x.concat(y) when you are not
33 // certain that x is an Array (x could be a string with concat method).
35 - if (isArray(current)) {
34 + if (Array.isArray(current)) {
35 return current.concat(next);
36 }
37
39 - if (isArray(next)) {
38 + if (Array.isArray(next)) {
39 return [current].concat(next);
40 }
41
packages/react-native-renderer/src/legacy-events/accumulateInto.js
+3 -4
@@ -8,7 +8,6 @@
8 */
9
10 import invariant from 'shared/invariant';
11 -import isArray from 'shared/isArray';
11
12 /**
13 * Accumulates items that must not be null or undefined into the first one. This
@@ -38,8 +37,8 @@ function accumulateInto<T>(
37
38 // Both are not empty. Warning: Never call x.concat(y) when you are not
39 // certain that x is an Array (x could be a string with concat method).
41 - if (isArray(current)) {
42 - if (isArray(next)) {
40 + if (Array.isArray(current)) {
41 + if (Array.isArray(next)) {
42 current.push.apply(current, next);
43 return current;
44 }
@@ -47,7 +46,7 @@ function accumulateInto<T>(
46 return current;
47 }
48
50 - if (isArray(next)) {
49 + if (Array.isArray(next)) {
50 // A bit too dangerous to mutate `next`.
51 return [current].concat(next);
52 }
packages/react-noop-renderer/src/createReactNoop.js
+4 -5
@@ -21,7 +21,6 @@ import type {RootTag} from 'react-reconciler/src/ReactRootTags';
21
22 import * as Scheduler from 'scheduler/unstable_mock';
23 import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
24 -import isArray from 'shared/isArray';
24 import {
25 DefaultEventPriority,
26 IdleEventPriority,
@@ -605,7 +604,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
604 if (typeof child === 'string') {
605 return child;
606 }
608 - if (isArray(child)) {
607 + if (Array.isArray(child)) {
608 if (child.length === 0) {
609 return null;
610 }
@@ -619,7 +618,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
618 }
619 return children;
620 }
622 - if (isArray(child.children)) {
621 + if (Array.isArray(child.children)) {
622 // This is an instance.
623 const instance: Instance = (child: any);
624 const children = childToJSX(instance.children, instance.text);
@@ -669,7 +668,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
668 if (children === null) {
669 return null;
670 }
672 - if (isArray(children)) {
671 + if (Array.isArray(children)) {
672 return {
673 $$typeof: REACT_ELEMENT_TYPE,
674 type: REACT_FRAGMENT_TYPE,
@@ -688,7 +687,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
687 if (children === null) {
688 return null;
689 }
691 - if (isArray(children)) {
690 + if (Array.isArray(children)) {
691 return {
692 $$typeof: REACT_ELEMENT_TYPE,
693 type: REACT_FRAGMENT_TYPE,
packages/react-reconciler/src/ReactChildFiber.new.js
+2 -1
@@ -31,7 +31,6 @@ import {
31 SimpleMemoComponent,
32 } from './ReactWorkTags';
33 import invariant from 'shared/invariant';
34 -import isArray from 'shared/isArray';
34 import {
35 warnAboutStringRefs,
36 enableLazyElements,
@@ -98,6 +97,8 @@ if (__DEV__) {
97 };
98 }
99
100 +const isArray = Array.isArray;
101 +
102 function coerceRef(
103 returnFiber: Fiber,
104 current: Fiber | null,
packages/react-reconciler/src/ReactChildFiber.old.js
+2 -1
@@ -11,7 +11,6 @@ import type {ReactElement} from 'shared/ReactElementType';
11 import type {ReactPortal} from 'shared/ReactTypes';
12 import type {Fiber} from './ReactInternalTypes';
13 import type {Lanes} from './ReactFiberLane.old';
14 -import isArray from 'shared/isArray';
14
15 import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
16 import {Placement, ChildDeletion} from './ReactFiberFlags';
@@ -98,6 +97,8 @@ if (__DEV__) {
97 };
98 }
99
100 +const isArray = Array.isArray;
101 +
102 function coerceRef(
103 returnFiber: Fiber,
104 current: Fiber | null,
packages/react-reconciler/src/ReactFiberClassComponent.new.js
+1 -1
@@ -29,7 +29,6 @@ import shallowEqual from 'shared/shallowEqual';
29 import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
30 import getComponentNameFromType from 'shared/getComponentNameFromType';
31 import invariant from 'shared/invariant';
32 -import isArray from 'shared/isArray';
32 import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
33
34 import {resolveDefaultProps} from './ReactFiberLazyComponent.new';
@@ -75,6 +74,7 @@ import {
74 } from './SchedulingProfiler';
75
76 const fakeInternalInstance = {};
77 +const isArray = Array.isArray;
78
79 // React.Component uses a shared frozen object by default.
80 // We'll use it to determine whether we need to initialize legacy refs.
packages/react-reconciler/src/ReactFiberClassComponent.old.js
+1 -1
@@ -29,7 +29,6 @@ import shallowEqual from 'shared/shallowEqual';
29 import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
30 import getComponentNameFromType from 'shared/getComponentNameFromType';
31 import invariant from 'shared/invariant';
32 -import isArray from 'shared/isArray';
32 import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
33
34 import {resolveDefaultProps} from './ReactFiberLazyComponent.old';
@@ -75,6 +74,7 @@ import {
74 } from './SchedulingProfiler';
75
76 const fakeInternalInstance = {};
77 +const isArray = Array.isArray;
78
79 // React.Component uses a shared frozen object by default.
80 // We'll use it to determine whether we need to initialize legacy refs.
packages/react-reconciler/src/ReactFiberReconciler.new.js
+5 -6
@@ -34,7 +34,6 @@ import {
34 } from './ReactWorkTags';
35 import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
36 import invariant from 'shared/invariant';
37 -import isArray from 'shared/isArray';
37 import {enableSchedulingProfiler} from 'shared/ReactFeatureFlags';
38 import ReactSharedInternals from 'shared/ReactSharedInternals';
39 import {getPublicInstance} from './ReactFiberHostConfig';
@@ -483,9 +482,9 @@ if (__DEV__) {
482 index: number,
483 ) => {
484 const key = path[index];
486 - const updated = isArray(obj) ? obj.slice() : {...obj};
485 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
486 if (index + 1 === path.length) {
488 - if (isArray(updated)) {
487 + if (Array.isArray(updated)) {
488 updated.splice(((key: any): number), 1);
489 } else {
490 delete updated[key];
@@ -511,12 +510,12 @@ if (__DEV__) {
510 index: number,
511 ) => {
512 const oldKey = oldPath[index];
514 - const updated = isArray(obj) ? obj.slice() : {...obj};
513 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
514 if (index + 1 === oldPath.length) {
515 const newKey = newPath[index];
516 // $FlowFixMe number or string is fine here
517 updated[newKey] = updated[oldKey];
519 - if (isArray(updated)) {
518 + if (Array.isArray(updated)) {
519 updated.splice(((oldKey: any): number), 1);
520 } else {
521 delete updated[oldKey];
@@ -565,7 +564,7 @@ if (__DEV__) {
564 return value;
565 }
566 const key = path[index];
568 - const updated = isArray(obj) ? obj.slice() : {...obj};
567 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
568 // $FlowFixMe number or string is fine here
569 updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
570 return updated;
packages/react-reconciler/src/ReactFiberReconciler.old.js
+5 -6
@@ -34,7 +34,6 @@ import {
34 } from './ReactWorkTags';
35 import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
36 import invariant from 'shared/invariant';
37 -import isArray from 'shared/isArray';
37 import {enableSchedulingProfiler} from 'shared/ReactFeatureFlags';
38 import ReactSharedInternals from 'shared/ReactSharedInternals';
39 import {getPublicInstance} from './ReactFiberHostConfig';
@@ -483,9 +482,9 @@ if (__DEV__) {
482 index: number,
483 ) => {
484 const key = path[index];
486 - const updated = isArray(obj) ? obj.slice() : {...obj};
485 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
486 if (index + 1 === path.length) {
488 - if (isArray(updated)) {
487 + if (Array.isArray(updated)) {
488 updated.splice(((key: any): number), 1);
489 } else {
490 delete updated[key];
@@ -511,12 +510,12 @@ if (__DEV__) {
510 index: number,
511 ) => {
512 const oldKey = oldPath[index];
514 - const updated = isArray(obj) ? obj.slice() : {...obj};
513 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
514 if (index + 1 === oldPath.length) {
515 const newKey = newPath[index];
516 // $FlowFixMe number or string is fine here
517 updated[newKey] = updated[oldKey];
519 - if (isArray(updated)) {
518 + if (Array.isArray(updated)) {
519 updated.splice(((oldKey: any): number), 1);
520 } else {
521 delete updated[oldKey];
@@ -565,7 +564,7 @@ if (__DEV__) {
564 return value;
565 }
566 const key = path[index];
568 - const updated = isArray(obj) ? obj.slice() : {...obj};
567 + const updated = Array.isArray(obj) ? obj.slice() : {...obj};
568 // $FlowFixMe number or string is fine here
569 updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
570 return updated;
packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js
+1 -2
@@ -14,7 +14,6 @@ import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
14 import JSResourceReference from 'JSResourceReference';
15
16 import hasOwnProperty from 'shared/hasOwnProperty';
17 -import isArray from 'shared/isArray';
17
18 export type ModuleReference<T> = JSResourceReference<T>;
19
@@ -83,7 +82,7 @@ function convertModelToJSON(
82 ): JSONValue {
83 const json = resolveModelToJSON(request, parent, key, model);
84 if (typeof json === 'object' && json !== null) {
86 - if (isArray(json)) {
85 + if (Array.isArray(json)) {
86 const jsonArray: Array<JSONValue> = [];
87 for (let i = 0; i < json.length; i++) {
88 jsonArray[i] = convertModelToJSON(request, json, '' + i, json[i]);
packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js
+2 -2
@@ -8,9 +8,9 @@
8 */
9
10 import type {RowEncoding, JSONValue} from './ReactFlightNativeRelayProtocol';
11 +
12 import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
13 import hasOwnProperty from 'shared/hasOwnProperty';
13 -import isArray from 'shared/isArray';
14 import JSResourceReferenceImpl from 'JSResourceReferenceImpl';
15
16 export type ModuleReference<T> = JSResourceReferenceImpl<T>;
@@ -80,7 +80,7 @@ function convertModelToJSON(
80 ): JSONValue {
81 const json = resolveModelToJSON(request, parent, key, model);
82 if (typeof json === 'object' && json !== null) {
83 - if (isArray(json)) {
83 + if (Array.isArray(json)) {
84 const jsonArray: Array<JSONValue> = [];
85 for (let i = 0; i < json.length; i++) {
86 jsonArray[i] = convertModelToJSON(request, json, '' + i, json[i]);
packages/react-server/src/ReactFizzServer.js
+1 -2
@@ -51,7 +51,6 @@ import {REACT_ELEMENT_TYPE, REACT_SUSPENSE_TYPE} from 'shared/ReactSymbols';
51 import ReactSharedInternals from 'shared/ReactSharedInternals';
52
53 import invariant from 'shared/invariant';
54 -import isArray from 'shared/isArray';
54
55 const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
56
@@ -288,7 +287,7 @@ function renderNode(request: Request, task: Task, node: ReactNodeList): void {
287 return;
288 }
289
291 - if (isArray(node)) {
290 + if (Array.isArray(node)) {
291 if (node.length > 0) {
292 for (let i = 0; i < node.length; i++) {
293 renderNode(request, task, node[i]);
packages/react-server/src/ReactFlightServer.js
+2 -1
@@ -44,7 +44,8 @@ import {
44
45 import ReactSharedInternals from 'shared/ReactSharedInternals';
46 import invariant from 'shared/invariant';
47 -import isArray from 'shared/isArray';
47 +
48 +const isArray = Array.isArray;
49
50 type ReactJSONValue =
51 | string
packages/react/src/ReactChildren.js
+2 -3
@@ -10,7 +10,6 @@
10 import type {ReactNodeList} from 'shared/ReactTypes';
11
12 import invariant from 'shared/invariant';
13 -import isArray from 'shared/isArray';
13 import {
14 getIteratorFn,
15 REACT_ELEMENT_TYPE,
@@ -111,7 +110,7 @@ function mapIntoArray(
110 // so that it's consistent if the number of children grows:
111 const childKey =
112 nameSoFar === '' ? SEPARATOR + getElementKey(child, 0) : nameSoFar;
114 - if (isArray(mappedChild)) {
113 + if (Array.isArray(mappedChild)) {
114 let escapedChildKey = '';
115 if (childKey != null) {
116 escapedChildKey = escapeUserProvidedKey(childKey) + '/';
@@ -143,7 +142,7 @@ function mapIntoArray(
142 const nextNamePrefix =
143 nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
144
146 - if (isArray(children)) {
145 + if (Array.isArray(children)) {
146 for (let i = 0; i < children.length; i++) {
147 child = children[i];
148 nextName = nextNamePrefix + getElementKey(child, i);
packages/react/src/ReactElementValidator.js
+4 -5
@@ -23,7 +23,6 @@ import {
23 } from 'shared/ReactSymbols';
24 import {warnAboutSpreadingKeyToJSX} from 'shared/ReactFeatureFlags';
25 import checkPropTypes from 'shared/checkPropTypes';
26 -import isArray from 'shared/isArray';
26
27 import ReactCurrentOwner from './ReactCurrentOwner';
28 import {
@@ -169,7 +168,7 @@ function validateChildKeys(node, parentType) {
168 if (typeof node !== 'object') {
169 return;
170 }
172 - if (isArray(node)) {
171 + if (Array.isArray(node)) {
172 for (let i = 0; i < node.length; i++) {
173 const child = node[i];
174 if (isValidElement(child)) {
@@ -314,7 +313,7 @@ export function jsxWithValidation(
313 let typeString;
314 if (type === null) {
315 typeString = 'null';
317 - } else if (isArray(type)) {
316 + } else if (Array.isArray(type)) {
317 typeString = 'array';
318 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
319 typeString = `<${getComponentNameFromType(type.type) || 'Unknown'} />`;
@@ -353,7 +352,7 @@ export function jsxWithValidation(
352 const children = props.children;
353 if (children !== undefined) {
354 if (isStaticChildren) {
356 - if (isArray(children)) {
355 + if (Array.isArray(children)) {
356 for (let i = 0; i < children.length; i++) {
357 validateChildKeys(children[i], type);
358 }
@@ -438,7 +437,7 @@ export function createElementWithValidation(type, props, children) {
437 let typeString;
438 if (type === null) {
439 typeString = 'null';
441 - } else if (isArray(type)) {
440 + } else if (Array.isArray(type)) {
441 typeString = 'array';
442 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
443 typeString = `<${getComponentNameFromType(type.type) || 'Unknown'} />`;
packages/react/src/jsx/ReactJSXElementValidator.js
+3 -4
@@ -23,7 +23,6 @@ import {
23 } from 'shared/ReactSymbols';
24 import {warnAboutSpreadingKeyToJSX} from 'shared/ReactFeatureFlags';
25 import hasOwnProperty from 'shared/hasOwnProperty';
26 -import isArray from 'shared/isArray';
26 import {jsxDEV} from './ReactJSXElement';
27
28 import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
@@ -183,7 +182,7 @@ function validateChildKeys(node, parentType) {
182 if (typeof node !== 'object') {
183 return;
184 }
186 - if (isArray(node)) {
185 + if (Array.isArray(node)) {
186 for (let i = 0; i < node.length; i++) {
187 const child = node[i];
188 if (isValidElement(child)) {
@@ -330,7 +329,7 @@ export function jsxWithValidation(
329 let typeString;
330 if (type === null) {
331 typeString = 'null';
333 - } else if (isArray(type)) {
332 + } else if (Array.isArray(type)) {
333 typeString = 'array';
334 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
335 typeString = `<${getComponentNameFromType(type.type) || 'Unknown'} />`;
@@ -367,7 +366,7 @@ export function jsxWithValidation(
366 const children = props.children;
367 if (children !== undefined) {
368 if (isStaticChildren) {
370 - if (isArray(children)) {
369 + if (Array.isArray(children)) {
370 for (let i = 0; i < children.length; i++) {
371 validateChildKeys(children[i], type);
372 }
packages/shared/isArray.js deleted
-12
@@ -1,12 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -const isArray = Array.isArray;
11 -
12 -export default isArray;