Skip to content

Commit 83e7951

Browse files
committed
added possibility to change styles of input
new props will reset input value from store
1 parent b744909 commit 83e7951

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/TextField.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export default class TextField extends Component {
2323
focus() {
2424
this.refs.input.focus();
2525
}
26+
componentWillReceiveProps(props) {
27+
if (!this.state.isFocused) {
28+
this.setState({text: props.value})
29+
}
30+
}
2631
render() {
2732
let {
2833
label,
@@ -34,13 +39,14 @@ export default class TextField extends Component {
3439
onBlur,
3540
onChangeText,
3641
value,
42+
style,
3743
dense,
3844
...props
3945
} = this.props;
4046
return (
4147
<View style={dense ? styles.denseWrapper : styles.wrapper} ref="wrapper">
4248
<TextInput
43-
style={dense ? styles.denseTextInput : styles.textInput}
49+
style={[dense ? styles.denseTextInput : styles.textInput, style]}
4450
onFocus={() => {
4551
this.setState({isFocused: true});
4652
this.refs.floatingLabel.floatLabel();
@@ -87,6 +93,7 @@ TextField.propTypes = {
8793
duration: PropTypes.number,
8894
label: PropTypes.string,
8995
highlightColor: PropTypes.string,
96+
styles: PropTypes.any,
9097
onFocus: PropTypes.func,
9198
onBlur: PropTypes.func,
9299
onChangeText: PropTypes.func,

0 commit comments

Comments
 (0)