mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Better error reporting in UIView+ComponentViewProtocol
Summary: We need this to make crash logs more actionable. For now we know that those asserts fire so we should make them actionable. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D23580103 fbshipit-source-id: 8532e33b016e738a4f128c9b547c33d204610bcc
This commit is contained in:
1 parent
b7b0e23202
commit
7e899348c7
1 file changed
+17
-4
@@ -30,16 +30,29 @@ using namespace facebook::react;
|
||||
|
||||
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
||||
{
|
||||
RCTAssert(childComponentView.superview == nil, @"Attempt to mount already mounted component view.");
|
||||
RCTAssert(
|
||||
childComponentView.superview == nil,
|
||||
@"Attempt to mount already mounted component view. (parent: %@, child: %@, index: %@)",
|
||||
self,
|
||||
childComponentView,
|
||||
@(index));
|
||||
[self insertSubview:childComponentView atIndex:index];
|
||||
}
|
||||
|
||||
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
||||
{
|
||||
RCTAssert(childComponentView.superview == self, @"Attempt to unmount improperly mounted component view.");
|
||||
RCTAssert(
|
||||
[self.subviews objectAtIndex:index] == childComponentView,
|
||||
@"Attempt to unmount improperly mounted component view.");
|
||||
childComponentView.superview == self,
|
||||
@"Attempt to unmount a view which is mounted inside different view. (parent: %@, child: %@, index: %@)",
|
||||
self,
|
||||
childComponentView,
|
||||
@(index));
|
||||
RCTAssert(
|
||||
(self.subviews.count > index) && [self.subviews objectAtIndex:index] == childComponentView,
|
||||
@"Attempt to unmount a view which has a different index. (parent: %@, child: %@, index: %@)",
|
||||
self,
|
||||
childComponentView,
|
||||
@(index));
|
||||
|
||||
[childComponentView removeFromSuperview];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user