Skip to content

Commit d09a4d9

Browse files
committed
fix: "onKeyPress" prop of TextInput
The replacement text in "shouldChangeTextInRange:replacementText:" may be a mutable string, so we need to copy it to prevent changes to the "_predictedText" internal property.
1 parent 58c992b commit d09a4d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
279279
if (_predictedText) {
280280
_predictedText = [_predictedText stringByReplacingCharactersInRange:range withString:text];
281281
} else {
282-
_predictedText = text;
282+
_predictedText = [text copy];
283283
}
284284

285285
if (_onTextInput) {

0 commit comments

Comments
 (0)