diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index f64f8b7d3..aae34be74 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -768,7 +768,7 @@ RCT_EXPORT_METHOD(removeSubviewsFromContainerWithID:(nonnull NSNumber *)containe // So, let's temporary restore the view back after removing. // To do so, we have to memorize original `superview` (which can differ from `container`) and an index of removed view. UIView *originalSuperview = removedChild.superview; - NSUInteger originalIndex = [originalSuperview.subviews indexOfObject:removedChild]; + NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:removedChild]; [container removeReactSubview:removedChild]; [originalSuperview insertSubview:removedChild atIndex:originalIndex]; @@ -821,7 +821,7 @@ RCT_EXPORT_METHOD(replaceExistingNonRootView:(nonnull NSNumber *)reactTag return; } - NSUInteger indexOfView = [superShadowView.reactSubviews indexOfObject:shadowView]; + NSUInteger indexOfView = [superShadowView.reactSubviews indexOfObjectIdenticalTo:shadowView]; RCTAssert(indexOfView != NSNotFound, @"View's superview doesn't claim it as subview (id %@)", reactTag); NSArray *removeAtIndices = @[@(indexOfView)]; NSArray *addTags = @[newReactTag];