Skip to content

Commit

Permalink
Use react_native_assert instead of NSLog
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Dec 6, 2023
1 parent 475ea73 commit 5e4212e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions ios/MarkdownTextInputViewView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,15 @@ - (void)didMoveToWindow {
NSUInteger currentIndex = [viewsArray indexOfObject:self];
#endif /* RCT_NEW_ARCH_ENABLED */

if (currentIndex == 0 || currentIndex == NSNotFound) {
NSLog(@"Error while finding current component.");
return;
}
react_native_assert(currentIndex != 0 && currentIndex != NSNotFound && "Error while finding current component.");
UIView *view = [viewsArray objectAtIndex:currentIndex - 1];

#ifdef RCT_NEW_ARCH_ENABLED
if (![view isKindOfClass:[RCTTextInputComponentView class]]) {
NSLog(@"Previous sibling component is not an instance of RCTTextInputComponentView.");
return;
}
react_native_assert([view isKindOfClass:[RCTTextInputComponentView class]] && "Previous sibling component is not an instance of RCTTextInputComponentView.");
RCTTextInputComponentView *textInput = (RCTTextInputComponentView *)view;
UIView<RCTBackedTextInputViewProtocol> *backedTextInputView = [textInput valueForKey:@"_backedTextInputView"];
#else
if (![view isKindOfClass:[RCTBaseTextInputView class]]) {
NSLog(@"Previous sibling component is not an instance of RCTBaseTextInputView.");
return;
}
react_native_assert([view isKindOfClass:[RCTBaseTextInputView class]] && "Previous sibling component is not an instance of RCTBaseTextInputView.");
RCTBaseTextInputView *textInput = (RCTBaseTextInputView *)view;
UIView<RCTBackedTextInputViewProtocol> *backedTextInputView = textInput.backedTextInputView;
#endif /* RCT_NEW_ARCH_ENABLED */
Expand All @@ -52,7 +43,7 @@ - (void)didMoveToWindow {
RCTUITextView *textView = (RCTUITextView *)backedTextInputView;
[textView setMarkdownEnabled:YES];
} else {
NSLog(@"Cannot enable Markdown for this type of TextInput.");
react_native_assert(false && "Cannot enable Markdown for this type of TextInput.");
}
}

Expand Down

0 comments on commit 5e4212e

Please sign in to comment.