From 5bccfe584378ea5c5ef30607492a437ba3068121 Mon Sep 17 00:00:00 2001 From: Jameel Mukadam Date: Tue, 6 Jun 2017 13:38:17 +0200 Subject: [PATCH] =?UTF-8?q?Bug=20Fix:=20if=20you=20pass=20a=20null=20value?= =?UTF-8?q?=20to=20the=20=E2=80=98value=E2=80=99=20prop=20it=20returns=20a?= =?UTF-8?q?n=20undefined=20error=20so=20I=20added=20a=20undefined=20check?= =?UTF-8?q?=20to=20the=20value=20prop=20so=20if=20value=20is=20a=20null=20?= =?UTF-8?q?then=20it=20sets=20state=20as=20a=20blank=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/TextField.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/TextField.js b/lib/TextField.js index d42523a..c7182fd 100644 --- a/lib/TextField.js +++ b/lib/TextField.js @@ -10,7 +10,7 @@ export default class TextField extends Component { super(props, context); this.state = { isFocused: false, - text: props.value, + text: props.value || '', height: props.height }; } @@ -28,7 +28,7 @@ export default class TextField extends Component { } componentWillReceiveProps(nextProps: Object){ if(this.props.text !== nextProps.value){ - nextProps.value.length !== 0 ? + (nextProps.value && nextProps.value.length !== 0) ? this.refs.floatingLabel.floatLabel() : this.refs.floatingLabel.sinkLabel(); this.setState({text: nextProps.value});