Skip to content

Commit

Permalink
fix: don't update TextInput content if it's not editable (#608)
Browse files Browse the repository at this point in the history
Prevent component to update current value when it isn't editable

Resolves #589
  • Loading branch information
brunohkbx authored and satya164 committed Oct 18, 2018
1 parent 39ceec6 commit 56840ee
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class TextInput extends React.Component<Props, State> {
disabled: false,
error: false,
multiline: false,
editable: true,
render: props => <NativeTextInput {...props} />,
};

Expand Down Expand Up @@ -327,6 +328,8 @@ class TextInput extends React.Component<Props, State> {
};

_handleChangeText = (value: string) => {
if (!this.props.editable) return;

this.setState({ value });
this.props.onChangeText && this.props.onChangeText(value);
};
Expand Down

0 comments on commit 56840ee

Please sign in to comment.