I am trying to create a country picker input, so I am using the library 'react-native-country-picker-modal' and it's supposed to work like this:
but when i follow the documentation i got a bad result
The dropdown list works fine, I can choose the country, but the flag does not appear after I select it.
Here is the code I wrote:
export const CountrySelect = () => {
const [country, setCountry] = useState("")
return (
<View style={styles.container}>
<CountryPicker
withFilter
withFlag
withCountryNameButton
withAlphaFilter
withCallingCode
withEmoji
onSelect={(country) => setCountry(country)} />
</View>
);
};
and i got this result, as you see, the flag refuse to appear
The state is not used in the picker. Set countryCode
something like this:
<CountryPicker
countryCode={country.cca2}
withFilter
withFlag
withCountryNameButton
withAlphaFilter
withCallingCode
withEmoji
onSelect={(country) => setCountry(country)}
/>