diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index e9fdf0b654b5a..024a903dbd915 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -1231,9 +1231,7 @@ function ChildReconciler(shouldTrackSideEffects) { } // Handle object types - const isObject = typeof newChild === 'object' && newChild !== null; - - if (isObject) { + if (typeof newChild === 'object' && newChild !== null) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return placeSingleChild( @@ -1266,6 +1264,26 @@ function ChildReconciler(shouldTrackSideEffects) { ); } } + + if (isArray(newChild)) { + return reconcileChildrenArray( + returnFiber, + currentFirstChild, + newChild, + lanes, + ); + } + + if (getIteratorFn(newChild)) { + return reconcileChildrenIterator( + returnFiber, + currentFirstChild, + newChild, + lanes, + ); + } + + throwOnInvalidObjectType(returnFiber, newChild); } if (typeof newChild === 'string' || typeof newChild === 'number') { @@ -1279,28 +1297,6 @@ function ChildReconciler(shouldTrackSideEffects) { ); } - if (isArray(newChild)) { - return reconcileChildrenArray( - returnFiber, - currentFirstChild, - newChild, - lanes, - ); - } - - if (getIteratorFn(newChild)) { - return reconcileChildrenIterator( - returnFiber, - currentFirstChild, - newChild, - lanes, - ); - } - - if (isObject) { - throwOnInvalidObjectType(returnFiber, newChild); - } - if (__DEV__) { if (typeof newChild === 'function') { warnOnFunctionType(returnFiber); diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index 34120a641ba3b..80b4fc35512d0 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -1231,9 +1231,7 @@ function ChildReconciler(shouldTrackSideEffects) { } // Handle object types - const isObject = typeof newChild === 'object' && newChild !== null; - - if (isObject) { + if (typeof newChild === 'object' && newChild !== null) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return placeSingleChild( @@ -1266,6 +1264,26 @@ function ChildReconciler(shouldTrackSideEffects) { ); } } + + if (isArray(newChild)) { + return reconcileChildrenArray( + returnFiber, + currentFirstChild, + newChild, + lanes, + ); + } + + if (getIteratorFn(newChild)) { + return reconcileChildrenIterator( + returnFiber, + currentFirstChild, + newChild, + lanes, + ); + } + + throwOnInvalidObjectType(returnFiber, newChild); } if (typeof newChild === 'string' || typeof newChild === 'number') { @@ -1279,28 +1297,6 @@ function ChildReconciler(shouldTrackSideEffects) { ); } - if (isArray(newChild)) { - return reconcileChildrenArray( - returnFiber, - currentFirstChild, - newChild, - lanes, - ); - } - - if (getIteratorFn(newChild)) { - return reconcileChildrenIterator( - returnFiber, - currentFirstChild, - newChild, - lanes, - ); - } - - if (isObject) { - throwOnInvalidObjectType(returnFiber, newChild); - } - if (__DEV__) { if (typeof newChild === 'function') { warnOnFunctionType(returnFiber);