Using `indexOfObjectIdenticalTo` instead of `indexOfObject` in RCTUIManager
Summary: This should be much more performant (and it better illustrates the intension of the code). The fix was suggested by Adlai-Holler. Reviewed By: mmmulani Differential Revision: D5851595 fbshipit-source-id: 45d172a5fa796549c6dcea8f35c5cbb2a4c2d2e0
This commit is contained in:
parent
d7f6208649
commit
9d9e250d28
|
@ -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<NSNumber *> *removeAtIndices = @[@(indexOfView)];
|
||||
NSArray<NSNumber *> *addTags = @[newReactTag];
|
||||
|
|
Loading…
Reference in New Issue