GeezerVison is showing github.com — Revert "Remove redundant initial of isArray (#21163)" · react/react@b4f119c
File treeExpand file treeCollapse file tree Open diff view settings eslint-plugin-react-hooks/src react-devtools-shared/src/backend react-native-renderer/src react-server-dom-relay/src react-server-native-relay/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -145,8 +145,6 @@ export default { | 145 | 145 | componentScope = currentScope; | 146 | 146 | } | 147 | 147 |
| 148 | | - const isArray = Array.isArray; | 149 | | - | 150 | 148 | // Next we'll define a few helpers that helps us | 151 | 149 | // tell if some values don't have to be declared as deps. | 152 | 150 |
| @@ -159,7 +157,7 @@ export default { | 159 | 157 | // ^^^ true for this reference | 160 | 158 | // False for everything else. | 161 | 159 | function isStableKnownHookValue(resolved) { | 162 | | - if (!isArray(resolved.defs)) { | | 160 | + if (!Array.isArray(resolved.defs)) { | 163 | 161 | return false; | 164 | 162 | } | 165 | 163 | const def = resolved.defs[0]; | @@ -228,7 +226,7 @@ export default { | 228 | 226 | if ( | 229 | 227 | id.type === 'ArrayPattern' && | 230 | 228 | id.elements.length === 2 && | 231 | | - isArray(resolved.identifiers) | | 229 | + Array.isArray(resolved.identifiers) | 232 | 230 | ) { | 233 | 231 | // Is second tuple value the same reference we're checking? | 234 | 232 | if (id.elements[1] === resolved.identifiers[0]) { | @@ -257,7 +255,7 @@ export default { | 257 | 255 | } else if (name === 'useTransition') { | 258 | 256 | if ( | 259 | 257 | id.type === 'ArrayPattern' && | 260 | | - isArray(resolved.identifiers) | | 258 | + Array.isArray(resolved.identifiers) | 261 | 259 | ) { | 262 | 260 | // Is first tuple value the same reference we're checking? | 263 | 261 | if (id.elements[0] === resolved.identifiers[0]) { | @@ -272,7 +270,7 @@ export default { | 272 | 270 |
| 273 | 271 | // Some are just functions that don't reference anything dynamic. | 274 | 272 | function isFunctionWithoutCapturedValues(resolved) { | 275 | | - if (!isArray(resolved.defs)) { | | 273 | + if (!Array.isArray(resolved.defs)) { | 276 | 274 | return false; | 277 | 275 | } | 278 | 276 | const def = resolved.defs[0]; | |
Collapse file Copy file name to clipboardExpand all lines: packages/jest-react/src/JestReact.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | import {REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols'; | 9 | 9 |
| 10 | 10 | import invariant from 'shared/invariant'; | 11 | | -import isArray from 'shared/isArray'; | 12 | 11 |
| 13 | 12 | function captureAssertion(fn) { | 14 | 13 | // Trick to use a Jest matcher inside another Jest matcher. `fn` contains an | @@ -43,7 +42,7 @@ export function unstable_toMatchRenderedOutput(root, expectedJSX) { | 43 | 42 | let actualJSX; | 44 | 43 | if (actualJSON === null || typeof actualJSON === 'string') { | 45 | 44 | actualJSX = actualJSON; | 46 | | - } else if (isArray(actualJSON)) { | | 45 | + } else if (Array.isArray(actualJSON)) { | 47 | 46 | if (actualJSON.length === 0) { | 48 | 47 | actualJSX = null; | 49 | 48 | } else if (actualJSON.length === 1) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/renderer.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,7 +105,6 @@ import type { | 105 | 105 | ElementType, | 106 | 106 | } from 'react-devtools-shared/src/types'; | 107 | 107 | import is from 'shared/objectIs'; | 108 | | -import isArray from 'shared/isArray'; | 109 | 108 |
| 110 | 109 | type getDisplayNameForFiberType = (fiber: Fiber) => string | null; | 111 | 110 | type getTypeSymbolType = (type: any) => Symbol | number; | @@ -1138,7 +1137,7 @@ export function attach( | 1138 | 1137 | memoizedState.hasOwnProperty('create') && | 1139 | 1138 | memoizedState.hasOwnProperty('destroy') && | 1140 | 1139 | memoizedState.hasOwnProperty('deps') && | 1141 | | - (memoizedState.deps === null || isArray(memoizedState.deps)) && | | 1140 | + (memoizedState.deps === null || Array.isArray(memoizedState.deps)) && | 1142 | 1141 | memoizedState.hasOwnProperty('next') | 1143 | 1142 | ); | 1144 | 1143 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/utils.js +5-6Lines changed: 5 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | import {copy} from 'clipboard-js'; | 11 | 11 | import {dehydrate} from '../hydration'; | 12 | | -import isArray from 'shared/isArray'; | 13 | 12 |
| 14 | 13 | import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Components/types'; | 15 | 14 |
| @@ -62,9 +61,9 @@ export function copyWithDelete( | 62 | 61 | index: number = 0, | 63 | 62 | ): Object | Array<any> { | 64 | 63 | const key = path[index]; | 65 | | - const updated = isArray(obj) ? obj.slice() : {...obj}; | | 64 | + const updated = Array.isArray(obj) ? obj.slice() : {...obj}; | 66 | 65 | if (index + 1 === path.length) { | 67 | | - if (isArray(updated)) { | | 66 | + if (Array.isArray(updated)) { | 68 | 67 | updated.splice(((key: any): number), 1); | 69 | 68 | } else { | 70 | 69 | delete updated[key]; | @@ -85,12 +84,12 @@ export function copyWithRename( | 85 | 84 | index: number = 0, | 86 | 85 | ): Object | Array<any> { | 87 | 86 | const oldKey = oldPath[index]; | 88 | | - const updated = isArray(obj) ? obj.slice() : {...obj}; | | 87 | + const updated = Array.isArray(obj) ? obj.slice() : {...obj}; | 89 | 88 | if (index + 1 === oldPath.length) { | 90 | 89 | const newKey = newPath[index]; | 91 | 90 | // $FlowFixMe number or string is fine here | 92 | 91 | updated[newKey] = updated[oldKey]; | 93 | | - if (isArray(updated)) { | | 92 | + if (Array.isArray(updated)) { | 94 | 93 | updated.splice(((oldKey: any): number), 1); | 95 | 94 | } else { | 96 | 95 | delete updated[oldKey]; | @@ -112,7 +111,7 @@ export function copyWithSet( | 112 | 111 | return value; | 113 | 112 | } | 114 | 113 | const key = path[index]; | 115 | | - const updated = isArray(obj) ? obj.slice() : {...obj}; | | 114 | + const updated = Array.isArray(obj) ? obj.slice() : {...obj}; | 116 | 115 | // $FlowFixMe number or string is fine here | 117 | 116 | updated[key] = copyWithSet(obj[key], path, value, index + 1); | 118 | 117 | return updated; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMSelect.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,6 @@ import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCur | 12 | 12 |
| 13 | 13 | import {checkControlledValueProps} from '../shared/ReactControlledValuePropTypes'; | 14 | 14 | import {getToStringValue, toString} from './ToStringValue'; | 15 | | -import isArray from 'shared/isArray'; | 16 | 15 |
| 17 | 16 | let didWarnValueDefaultValue; | 18 | 17 |
| @@ -46,15 +45,15 @@ function checkSelectPropTypes(props) { | 46 | 45 | if (props[propName] == null) { | 47 | 46 | continue; | 48 | 47 | } | 49 | | - const propNameIsArray = isArray(props[propName]); | 50 | | - if (props.multiple && !propNameIsArray) { | | 48 | + const isArray = Array.isArray(props[propName]); | | 49 | + if (props.multiple && !isArray) { | 51 | 50 | console.error( | 52 | 51 | 'The `%s` prop supplied to <select> must be an array if ' + | 53 | 52 | '`multiple` is true.%s', | 54 | 53 | propName, | 55 | 54 | getDeclarationErrorAddendum(), | 56 | 55 | ); | 57 | | - } else if (!props.multiple && propNameIsArray) { | | 56 | + } else if (!props.multiple && isArray) { | 58 | 57 | console.error( | 59 | 58 | 'The `%s` prop supplied to <select> must be a scalar ' + | 60 | 59 | 'value if `multiple` is false.%s', | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMTextarea.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | */ | 9 | 9 |
| 10 | 10 | import invariant from 'shared/invariant'; | 11 | | -import isArray from 'shared/isArray'; | 12 | 11 |
| 13 | 12 | import {checkControlledValueProps} from '../shared/ReactControlledValuePropTypes'; | 14 | 13 | import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCurrentFiber'; | 15 | 14 | import {getToStringValue, toString} from './ToStringValue'; | 16 | 15 | import type {ToStringValue} from './ToStringValue'; | | 16 | + | 17 | 17 | import {disableTextareaChildren} from 'shared/ReactFeatureFlags'; | 18 | 18 |
| 19 | 19 | let didWarnValDefaultVal = false; | @@ -100,7 +100,7 @@ export function initWrapperState(element: Element, props: Object) { | 100 | 100 | defaultValue == null, | 101 | 101 | 'If you supply `defaultValue` on a <textarea>, do not pass children.', | 102 | 102 | ); | 103 | | - if (isArray(children)) { | | 103 | + if (Array.isArray(children)) { | 104 | 104 | invariant( | 105 | 105 | children.length <= 1, | 106 | 106 | '<textarea> can only have at most one child.', | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactDOMServerFormatConfig.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,8 @@ import hyphenateStyleName from '../shared/hyphenateStyleName'; | 46 | 46 | import invariant from 'shared/invariant'; | 47 | 47 | import hasOwnProperty from 'shared/hasOwnProperty'; | 48 | 48 | import sanitizeURL from '../shared/sanitizeURL'; | 49 | | -import isArray from 'shared/isArray'; | | 49 | + | | 50 | +const isArray = Array.isArray; | 50 | 51 |
| 51 | 52 | // Per response, global state that is not contextual to the rendering subtree. | 52 | 53 | export type ResponseState = { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactPartialRenderer.js +5-6Lines changed: 5 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,6 @@ import type {ReactProvider, ReactContext} from 'shared/ReactTypes'; | 14 | 14 |
| 15 | 15 | import * as React from 'react'; | 16 | 16 | import invariant from 'shared/invariant'; | 17 | | -import isArray from 'shared/isArray'; | 18 | 17 | import getComponentNameFromType from 'shared/getComponentNameFromType'; | 19 | 18 | import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame'; | 20 | 19 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | @@ -1439,7 +1438,7 @@ class ReactDOMServerRenderer { | 1439 | 1438 | defaultValue == null, | 1440 | 1439 | 'If you supply `defaultValue` on a <textarea>, do not pass children.', | 1441 | 1440 | ); | 1442 | | - if (isArray(textareaChildren)) { | | 1441 | + if (Array.isArray(textareaChildren)) { | 1443 | 1442 | invariant( | 1444 | 1443 | textareaChildren.length <= 1, | 1445 | 1444 | '<textarea> can only have at most one child.', | @@ -1468,14 +1467,14 @@ class ReactDOMServerRenderer { | 1468 | 1467 | if (props[propName] == null) { | 1469 | 1468 | continue; | 1470 | 1469 | } | 1471 | | - const propNameIsArray = isArray(props[propName]); | 1472 | | - if (props.multiple && !propNameIsArray) { | | 1470 | + const isArray = Array.isArray(props[propName]); | | 1471 | + if (props.multiple && !isArray) { | 1473 | 1472 | console.error( | 1474 | 1473 | 'The `%s` prop supplied to <select> must be an array if ' + | 1475 | 1474 | '`multiple` is true.', | 1476 | 1475 | propName, | 1477 | 1476 | ); | 1478 | | - } else if (!props.multiple && propNameIsArray) { | | 1477 | + } else if (!props.multiple && isArray) { | 1479 | 1478 | console.error( | 1480 | 1479 | 'The `%s` prop supplied to <select> must be a scalar ' + | 1481 | 1480 | 'value if `multiple` is false.', | @@ -1516,7 +1515,7 @@ class ReactDOMServerRenderer { | 1516 | 1515 | value = optionChildren; | 1517 | 1516 | } | 1518 | 1517 | selected = false; | 1519 | | - if (isArray(selectValue)) { | | 1518 | + if (Array.isArray(selectValue)) { | 1520 | 1519 | // multiple | 1521 | 1520 | for (let j = 0; j < selectValue.length; j++) { | 1522 | 1521 | if ('' + selectValue[j] === value) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/test-utils/ReactTestUtils.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,6 @@ import { | 24 | 24 | rethrowCaughtError, | 25 | 25 | invokeGuardedCallbackAndCatchFirstError, | 26 | 26 | } from 'shared/ReactErrorUtils'; | 27 | | -import isArray from 'shared/isArray'; | 28 | 27 |
| 29 | 28 | // Keep in sync with ReactDOM.js, and ReactTestUtilsAct.js: | 30 | 29 | const EventInternals = | @@ -98,7 +97,7 @@ function validateClassInstance(inst, methodName) { | 98 | 97 | } | 99 | 98 | let received; | 100 | 99 | const stringified = '' + inst; | 101 | | - if (isArray(inst)) { | | 100 | + if (Array.isArray(inst)) { | 102 | 101 | received = 'an array'; | 103 | 102 | } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) { | 104 | 103 | received = 'a DOM node'; | @@ -198,7 +197,7 @@ function scryRenderedDOMComponentsWithClass(root, classNames) { | 198 | 197 | } | 199 | 198 | const classList = className.split(/\s+/); | 200 | 199 |
| 201 | | - if (!isArray(classNames)) { | | 200 | + if (!Array.isArray(classNames)) { | 202 | 201 | invariant( | 203 | 202 | classNames !== undefined, | 204 | 203 | 'TestUtils.scryRenderedDOMComponentsWithClass expects a ' + | @@ -366,7 +365,7 @@ function executeDispatch(event, listener, inst) { | 366 | 365 | function executeDispatchesInOrder(event) { | 367 | 366 | const dispatchListeners = event._dispatchListeners; | 368 | 367 | const dispatchInstances = event._dispatchInstances; | 369 | | - if (isArray(dispatchListeners)) { | | 368 | + if (Array.isArray(dispatchListeners)) { | 370 | 369 | for (let i = 0; i < dispatchListeners.length; i++) { | 371 | 370 | if (event.isPropagationStopped()) { | 372 | 371 | break; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeAttributePayload.js +6-7Lines changed: 6 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,6 @@ import { | 12 | 12 | deepDiffer, | 13 | 13 | flattenStyle, | 14 | 14 | } from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; | 15 | | -import isArray from 'shared/isArray'; | 16 | 15 |
| 17 | 16 | import type {AttributeConfiguration} from './ReactNativeTypes'; | 18 | 17 |
| @@ -52,7 +51,7 @@ function restoreDeletedValuesInNestedArray( | 52 | 51 | node: NestedNode, | 53 | 52 | validAttributes: AttributeConfiguration, | 54 | 53 | ) { | 55 | | - if (isArray(node)) { | | 54 | + if (Array.isArray(node)) { | 56 | 55 | let i = node.length; | 57 | 56 | while (i-- && removedKeyCount > 0) { | 58 | 57 | restoreDeletedValuesInNestedArray( | @@ -164,12 +163,12 @@ function diffNestedProperty( | 164 | 163 | return updatePayload; | 165 | 164 | } | 166 | 165 |
| 167 | | - if (!isArray(prevProp) && !isArray(nextProp)) { | | 166 | + if (!Array.isArray(prevProp) && !Array.isArray(nextProp)) { | 168 | 167 | // Both are leaves, we can diff the leaves. | 169 | 168 | return diffProperties(updatePayload, prevProp, nextProp, validAttributes); | 170 | 169 | } | 171 | 170 |
| 172 | | - if (isArray(prevProp) && isArray(nextProp)) { | | 171 | + if (Array.isArray(prevProp) && Array.isArray(nextProp)) { | 173 | 172 | // Both are arrays, we can diff the arrays. | 174 | 173 | return diffNestedArrayProperty( | 175 | 174 | updatePayload, | @@ -179,7 +178,7 @@ function diffNestedProperty( | 179 | 178 | ); | 180 | 179 | } | 181 | 180 |
| 182 | | - if (isArray(prevProp)) { | | 181 | + if (Array.isArray(prevProp)) { | 183 | 182 | return diffProperties( | 184 | 183 | updatePayload, | 185 | 184 | // $FlowFixMe - We know that this is always an object when the input is. | @@ -213,7 +212,7 @@ function addNestedProperty( | 213 | 212 | return updatePayload; | 214 | 213 | } | 215 | 214 |
| 216 | | - if (!isArray(nextProp)) { | | 215 | + if (!Array.isArray(nextProp)) { | 217 | 216 | // Add each property of the leaf. | 218 | 217 | return addProperties(updatePayload, nextProp, validAttributes); | 219 | 218 | } | @@ -243,7 +242,7 @@ function clearNestedProperty( | 243 | 242 | return updatePayload; | 244 | 243 | } | 245 | 244 |
| 246 | | - if (!isArray(prevProp)) { | | 245 | + if (!Array.isArray(prevProp)) { | 247 | 246 | // Add each property of the leaf. | 248 | 247 | return clearProperties(updatePayload, prevProp, validAttributes); | 249 | 248 | } | |
|