| 45 | } |
| 46 | |
| 47 | componentDidUpdate() { |
| 48 | const newValue = this.props.value; |
| 49 | if (this.props.hasOwnProperty("value") && newValue !== this.state.value) { |
| 50 | this.setState({ |
| 51 | value: newValue, |
| 52 | }); |
| 53 | |
| 54 | // animate input if it's active state has changed with the new value |
| 55 | // and input is not focused currently. |
| 56 | const isFocused = this.inputRef().isFocused(); |
| 57 | if (!isFocused) { |
| 58 | const isActive = Boolean(newValue); |
| 59 | if (isActive !== this.isActive) { |
| 60 | this._toggle(isActive); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | _onLayout(event) { |
| 67 | this.setState({ |