-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot change Country when initialCountry is set #7
Comments
Same for me. Trying to change country but when select new one the dropdown option turns into the old one. I have to delete country code in order to change country. Any suggestions? |
Same issue |
Any clue on this? |
same issue |
Please make a PR and I will do my best to address the bug. I have been busy lately and I'm looking for help maintaining the project |
Here is some example code. I'm not seeing this issue.
|
same issue for me, i can't change country after select first time |
What version do you have installed? Also please share an your configuration and code so I can better debug |
export default function Login() {
const [countryISO, setCountryISO] = useState('sa');
const [phone, setPhone] = useState('');
return (
<SafeAreaView style={{ flex: 1, padding: 20 }}>
<Title style={{ textAlign: 'center', fontSize: 30, marginBottom: 30 }}>
Login to {'\n'} Your Account
</Title>
<PhoneInput
style={styles.phoneInput}
onSelectCountry={(iso2) => console.log(iso2)}
initialCountry="sa"
onChangePhoneNumber={setPhone}
/>
</SafeAreaView>
);
}
"react-native-phone-input": "^1.0.10",
|
Your
|
@zizzle6717 import { StackScreenProps } from '@react-navigation/stack';
import React from 'react';
import { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Button, Title } from 'react-native-paper';
import PhoneInput from 'react-native-phone-input';
import { SafeAreaView } from 'react-native-safe-area-context';
import theme from '../../constants/Theme';
import { RootStackParamList } from '../../types';
export default function Login({
navigation,
}: StackScreenProps<RootStackParamList>) {
const [phoneInput, setPhoneInput] = useState({
phone: '',
iso2: '',
});
console.log({ phoneInput });
return (
<SafeAreaView style={{ flex: 1, padding: 20, justifyContent: 'center' }}>
<Title
style={{
textAlign: 'center',
fontSize: 30,
marginBottom: 30,
fontWeight: 'bold',
}}
>
Login to {'\n'} Your Account
</Title>
<PhoneInput
style={styles.phoneInput}
// initialCountry={phoneInput.iso2}
onSelectCountry={(iso2) => {
console.log({ iso2 });
setPhoneInput({
...phoneInput,
iso2,
});
}}
onChangePhoneNumber={(phone: string, iso2: string) => {
console.log({ phone, iso2 });
setPhoneInput({
phone,
iso2,
});
}}
/>
<Button
mode="contained"
color={theme.colors.accent}
style={{ marginTop: 20, borderRadius: 8 }}
onPress={() => {
navigation.navigate('OTPVerification');
}}
labelStyle={{ fontSize: 17, paddingVertical: 8 }}
>
Get OTP
</Button>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
phoneInput: {
borderWidth: 1,
padding: 10,
borderRadius: 8,
borderColor: '#736899',
},
}); |
Feel free to open a PR |
Same issue. tested all v1 |
Same issue. Fixed in #20. Waiting for the merge, you guys can use this
|
Sorry for the delay. The confusion here was that I am using a custom (external) library for the picker (react-native-country-picker-modal). It uses the prop Thank you @ebaynaud for the PR! Please let me know if this is not resolved in the recent release (v1.1.0) |
It's resolved @zizzle6717 ! Thanks |
When i set initialCountry, the picker always return to this country, i can't change it.
Also happen when i select a country in the list, i can't change it anymore
The text was updated successfully, but these errors were encountered: