diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index f3d83f79d3a9ed..4a8ed67d28f268 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -333,7 +333,7 @@ - (void)textInputDidBeginEditing [_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] key:nil eventCount:_nativeEventCount]; } @@ -347,13 +347,13 @@ - (void)textInputDidEndEditing { [_eventDispatcher sendTextEventWithType:RCTTextEventTypeEnd reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] key:nil eventCount:_nativeEventCount]; [_eventDispatcher sendTextEventWithType:RCTTextEventTypeBlur reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] key:nil eventCount:_nativeEventCount]; } @@ -367,7 +367,7 @@ - (BOOL)textInputShouldReturn // (no connection to any specific "submitting" process). [_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] key:nil eventCount:_nativeEventCount]; @@ -422,7 +422,7 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range } } - NSString *previousText = backedTextInputView.attributedText.string ?: @""; + NSString *previousText = [backedTextInputView.attributedText.string copy] ?: @""; if (range.location + range.length > backedTextInputView.attributedText.string.length) { _predictedText = backedTextInputView.attributedText.string; @@ -468,7 +468,7 @@ - (void)textInputDidChange if (_onChange) { _onChange(@{ - @"text": self.attributedText.string, + @"text": [self.attributedText.string copy], @"target": self.reactTag, @"eventCount": @(_nativeEventCount), });