Skip to content

Commit

Permalink
added possibility to change styles of input
Browse files Browse the repository at this point in the history
new props will reset input value from store
  • Loading branch information
wtfil committed Mar 30, 2016
1 parent b744909 commit 83e7951
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export default class TextField extends Component {
focus() {
this.refs.input.focus();
}
componentWillReceiveProps(props) {
if (!this.state.isFocused) {
this.setState({text: props.value})
}
}
render() {
let {
label,
Expand All @@ -34,13 +39,14 @@ export default class TextField extends Component {
onBlur,
onChangeText,
value,
style,
dense,
...props
} = this.props;
return (
<View style={dense ? styles.denseWrapper : styles.wrapper} ref="wrapper">
<TextInput
style={dense ? styles.denseTextInput : styles.textInput}
style={[dense ? styles.denseTextInput : styles.textInput, style]}
onFocus={() => {
this.setState({isFocused: true});
this.refs.floatingLabel.floatLabel();
Expand Down Expand Up @@ -87,6 +93,7 @@ TextField.propTypes = {
duration: PropTypes.number,
label: PropTypes.string,
highlightColor: PropTypes.string,
styles: PropTypes.any,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onChangeText: PropTypes.func,
Expand Down

0 comments on commit 83e7951

Please sign in to comment.