xcarpentier / react-native-country-picker-modal

🇦🇶 Country picker provides a modal allowing a user to select a country from a list. It display a flag next to each country name.
https://reactnative.gallery/xcarpentier/country-picker
MIT License
1.08k stars 802 forks source link

'withCallingCodeButton' can't change #248

Closed mingxin-yang closed 4 years ago

mingxin-yang commented 5 years ago
         <CountryPicker
              ref={ref => {
                this.myCountryPicker = ref;
              }}
              countryCode={this.state.countryCode}
              onSelect={country => {
                this.setState({
                  countryCode: country.cca2,
                  callingCode: country.callingCode,
                  country: country
                });
              }}
              withFlagButton={false}
              withCallingCodeButton
              withAlphaFilter
              withCallingCode
              cancelText="Cancel"
            >

when I change country, the callingCodeButton can't change the code

jamjamlong266 commented 5 years ago

Yeah, i also got this problem. For now i just using a Text component to show the callingcode

`<CountryPicker countryCode={this.state.countryCode} theme="black" withCallingCode onSelect={country => { this.setState({ countryCode: country.cca2, callingCode: country.callingCode, }); }} />

{this.state.callingCode} <--- this to display the code`
franjorub commented 5 years ago

I have TypeError: undefined is not an object (evaluating 'countries[countryCode].callingCode') when withCallingCodeButton is true