diff --git a/lib/index.js b/lib/index.js index db864957..abc89b37 100644 --- a/lib/index.js +++ b/lib/index.js @@ -46,7 +46,9 @@ export default class PhoneInput extends Component { componentDidUpdate() { const { value, disabled } = this.props; - this.setState({ disabled }); + if (disabled != null && disabled !== this.state.disabled) { + this.setState({disabled}); + } if (value && value !== this.state.value) { this.setState({ value }); @@ -211,23 +213,23 @@ export default class PhoneInput extends Component { /> - { - this.picker = ref; - }} - selectedCountry={iso2} - onSubmit={this.selectCountry} - buttonColor={this.props.pickerButtonColor} - buttonTextStyle={this.props.pickerButtonTextStyle} - cancelText={this.props.cancelText} - cancelTextStyle={this.props.cancelTextStyle} - confirmText={this.props.confirmText} - confirmTextStyle={this.props.confirmTextStyle} - pickerBackgroundColor={this.props.pickerBackgroundColor} - itemStyle={this.props.pickerItemStyle} - onPressCancel={this.props.onPressCancel} - onPressConfirm={this.props.onPressConfirm} - /> + {this.props.shouldShowCountryPicker && { + this.picker = ref; + }} + selectedCountry={iso2} + onSubmit={this.selectCountry} + buttonColor={this.props.pickerButtonColor} + buttonTextStyle={this.props.pickerButtonTextStyle} + cancelText={this.props.cancelText} + cancelTextStyle={this.props.cancelTextStyle} + confirmText={this.props.confirmText} + confirmTextStyle={this.props.confirmTextStyle} + pickerBackgroundColor={this.props.pickerBackgroundColor} + itemStyle={this.props.pickerItemStyle} + onPressCancel={this.props.onPressCancel} + onPressConfirm={this.props.onPressConfirm} + />} ); } @@ -265,11 +267,13 @@ PhoneInput.propTypes = { confirmText: PropTypes.string, confirmTextTextStyle: styleType, disabled: PropTypes.bool, - allowZeroAfterCountryCode: PropTypes.bool + allowZeroAfterCountryCode: PropTypes.bool, + shouldShowCountryPicker: PropTypes.bool }; PhoneInput.defaultProps = { initialCountry: "us", disabled: false, - allowZeroAfterCountryCode: true + allowZeroAfterCountryCode: true, + shouldShowCountryPicker: true };