diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index 37890b074f03e4..8b7ef9dc644096 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -375,7 +375,7 @@ - (void)textInputDidBeginEditing [_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739) key:nil eventCount:_nativeEventCount]; } @@ -389,13 +389,13 @@ - (void)textInputDidEndEditing { [_eventDispatcher sendTextEventWithType:RCTTextEventTypeEnd reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739) key:nil eventCount:_nativeEventCount]; [_eventDispatcher sendTextEventWithType:RCTTextEventTypeBlur reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739) key:nil eventCount:_nativeEventCount]; } @@ -412,7 +412,7 @@ - (BOOL)textInputShouldReturn #endif // ]TODO(macOS Candidate ISS#2710739) [_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit reactTag:self.reactTag - text:self.backedTextInputView.attributedText.string + text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739) key:nil eventCount:_nativeEventCount]; #if TARGET_OS_OSX // [TODO(macOS Candidate ISS#2710739) @@ -475,7 +475,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin } } - NSString *previousText = backedTextInputView.attributedText.string ?: @""; + NSString *previousText = [backedTextInputView.attributedText.string copy] ?: @""; // TODO(OSS Candidate ISS#2710739) if (range.location + range.length > backedTextInputView.attributedText.string.length) { _predictedText = backedTextInputView.attributedText.string; @@ -522,7 +522,7 @@ - (void)textInputDidChange if (_onChange) { _onChange(@{ - @"text": self.attributedText.string, + @"text": [self.attributedText.string copy], // [TODO(macOS Candidate ISS#2710739) @"target": self.reactTag, @"eventCount": @(_nativeEventCount), });