Skip to content

Commit

Permalink
Only set TextInput value on value prop change
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoran committed Feb 19, 2024
1 parent 364c709 commit 7aa9dea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/usecase/buffers/ui/UndoTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const UndoTextInput = (props: Props): JSX.Element => {

const handleChangeText = (textValue: string) => {
lastValue.current = textValue;
onChangeText(textValue);
onChangeText && onChangeText(textValue);
};

React.useEffect(() => {
if (value !== lastValue.current) {
textInput.current.setNativeProps({ text: value });
lastValue.current = value;
textInput.current?.setNativeProps({ text: value });
}
});
}, [value]);

return (
<TextInput {...rest} ref={textInput} onChangeText={handleChangeText} />
Expand Down

0 comments on commit 7aa9dea

Please sign in to comment.