Skip to content

Commit

Permalink
feat: allow to make inputs uncontrolled with defaultValue (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbinda authored and Trancever committed May 16, 2019
1 parent 6a37dc9 commit 327749f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class TextInput extends React.Component<TextInputProps, State> {
error: new Animated.Value(this.props.error ? 1 : 0),
focused: false,
placeholder: this.props.error ? this.props.placeholder : '',
value: this.props.value,
value: this.props.value || this.props.defaultValue,
labelLayout: {
measured: false,
width: 0,
Expand All @@ -187,7 +187,8 @@ class TextInput extends React.Component<TextInputProps, State> {
if (
prevState.focused !== this.state.focused ||
prevState.value !== this.state.value ||
prevProps.error !== this.props.error
prevProps.error !== this.props.error ||
this.props.defaultValue
) {
// The label should be minimized if the text input is focused, or has text
// In minimized mode, the label moves up and becomes small
Expand Down

0 comments on commit 327749f

Please sign in to comment.