From 507fc2a0ca923939dc4700f965feacacb0ee3abc Mon Sep 17 00:00:00 2001 From: Johannes Nyman Date: Thu, 15 Feb 2018 09:26:02 +0100 Subject: [PATCH 1/2] Added prop 'showClearButton' --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 496c9a9..4f67485 100644 --- a/index.js +++ b/index.js @@ -105,7 +105,7 @@ class ProgressiveInput extends Component { }; _renderClearButton = () => { - if (this.state.showClearButton) { + if (this.state.showClearButton && this.props.showClearButton) { return ( this.clearInput()}> Date: Tue, 20 Feb 2018 09:47:56 +0100 Subject: [PATCH 2/2] Renamed to 'clearButtonEnabled' and added PropTypes --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4f67485..07a8d57 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ class ProgressiveInput extends Component { clearButtonColor: PropTypes.string, clearButtonSize: PropTypes.number, clearButtonStyle: PropTypes.object, + clearButtonEnabled: PropTypes.bool, activityIndicatorStyle: ActivityIndicator.propTypes.style, onBlur: PropTypes.func, onChangeText: PropTypes.func, @@ -105,7 +106,7 @@ class ProgressiveInput extends Component { }; _renderClearButton = () => { - if (this.state.showClearButton && this.props.showClearButton) { + if (this.state.showClearButton && this.props.clearButtonEnabled) { return ( this.clearInput()}> this.setState({ showClearButton: false }); + _onBlur = () => { + this.setState({ showClearButton: false }) + if (this.props.onBlur) { + this.props.onBlur(); + } + }; } const styles = StyleSheet.create({