Open AGSTRANGER opened 4 years ago
hi @patw0929 , I double check the current code and see that you only process the PreferredCountries
on componentDidMount(). So to fix this issue, we can simply adding a condition check in componentDidUpdate()
whether prop preferredCountries
is changed or not, then we can process preferred countries data again.
How do you think, @patw0929 ?
One more note:
The same issue may happen with onlyCountries
too, so we can add something like:
if onlyCountries
or preferredCountries
is changed, then processCountryData()
again.
I also have the same issue I have following code but still it shows all country flag instead of onlyCountries array I specified
<ReactIntlTelInput
containerClassName="intl-tel-input"
inputClassName="form-control"
ref={this.setInput.bind(this)}
onChange={this.onChange.bind(this)}
value={this.state.value}
autoHideDialCode={this.state.autoHideDialCode}
formatOnDisplay={this.state.formatOnDisplay}
inputProps={this.state.inputProps}
onlyCountries={this.state.onlyCountries}
preferredCountries={this.state.preferredCountries}
/>
I have ['in','us'] inside this.state.onlyCountries and ['in'] inside this.state.preferredCountries but there is effect in output of these two props.
What is wrong with it ? any help ?
Expected Behavior
When I click on a button to change the preferredCountries attribute value to "tn" which refers to Tunisia for example, the displayed country should display the Tunisia flag.
Current Behavior
So here's logged results when I click on the checkState button, the testChangeDefaultCountryFlagsToDisplayInPhoneNumberInput button and then the checkState button:
Possible Solution
Steps to Reproduce
Code:
These are the two functions that get triggered when I click on the buttons below the input:
This is the default value:
Environment
Detailed Description