From cb8f9ce1d10dc752843909ceee5032418c224de0 Mon Sep 17 00:00:00 2001 From: Adam Gleitman Date: Mon, 11 Apr 2022 16:38:28 -0700 Subject: [PATCH] Add a nil check to prevent a crash --- Libraries/Text/TextInput/RCTBaseTextInputView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index 4e43e5591d0658..f95717e83372e7 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -493,7 +493,7 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range if (range.location + range.length > backedTextInputView.attributedText.string.length) { _predictedText = backedTextInputView.attributedText.string; - } else { + } else if (text != nil) { // TODO(macOS GH#774): -[NSString stringByReplacingCharactersInRange:withString:] doesn't like when the replacement string is nil _predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range withString:text]; }