diff --git a/README.md b/README.md index eb29f50c9..c02791a3f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +*This project is an instance of original project made by [Patrick Wang](https://github.com/patw0929). +Because of the lack of activity on original repo, I have added some functionalities and published it on npmjs for my own personal use. +Copyright (c) 2015-2019 [Patrick Wang](https://github.com/patw0929).* + # React-Intl-Tel-Input [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) @@ -119,4 +123,3 @@ yarn run lint MIT Copyright (c) 2015-2019 patw. - diff --git a/src/components/IntlTelInput.js b/src/components/IntlTelInput.js index 03ec81a01..fef0f2c76 100644 --- a/src/components/IntlTelInput.js +++ b/src/components/IntlTelInput.js @@ -163,6 +163,10 @@ class IntlTelInput extends Component { if (this.props.allowDropdown !== prevProps.allowDropdown) { this.allowDropdown = this.props.allowDropdown; } + + if (this.props.defaultCountry !== prevProps.defaultCountry) { + this.updateFlagOnDefaultCountryChange(this.props.defaultCountry) + } } componentWillUnmount() { @@ -171,6 +175,11 @@ class IntlTelInput extends Component { this.unbindDocumentClick(); } + // Updates flag when value of defaultCountry props change + updateFlagOnDefaultCountryChange = (countryCode) => { + this.setFlag(countryCode, false) + }; + getTempCountry = countryCode => { if (countryCode === 'auto') { return 'auto'; @@ -211,7 +220,7 @@ class IntlTelInput extends Component { }; // select the given flag, update the placeholder and the active list item - // Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry + // Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry, updateFlagOnDefaultCountryChange setFlag = (countryCode, isInit) => { const prevCountry = this.selectedCountryData && this.selectedCountryData.iso2