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.07k stars 797 forks source link

select country doesnt disappear #409

Closed enesdumanli closed 3 years ago

enesdumanli commented 3 years ago

Issue Description

Select country button doesnt disappear when i select country. I want country name instead of select country but withCountryNameButton={true} not working.

Steps to Reproduce / Code Snippets

<View style={{ position: 'absolute', bottom: '20%' }}> <CountryPicker onSelect={(item) => setSelectedCountry(item)} withModal={true} withCountryNameButton={true} />

{selectedCountry.name}
        </View>

Expected Results

i wanna see country name instead of select country

Additional Information

Boubaker93 commented 3 years ago

If i understood you very well, the prop withCountryNameButton makes you show the country name once it is selected other wise it will always show the string select country and you can change that by passing the placeholder prop in CountryPicker (not mentioned in README). Also dont forget to add the countryCode prop in CountryPicker to show selected country other wise it will always show select country. Here is an example :

<CountryPicker
   onSelect={(item) => setSelectedCountry(item)}
   withModal
   withCountryNameButton
   visible={countryPickerVisible}
   countryCode={selectedCountry.cca2}
   placeholder="Your placeholder"
/>
enesdumanli commented 3 years ago

thanks for your answer but its not working either. i want select country to doesnt show after i choose country. i want country name for example argentina instead of placeholder. withCountryNameButton should work but i have no idea why it doesnt work.

Boubaker93 commented 3 years ago

In the example you provided you are not passing countyCode prop, you should pass it like i mentioned in the example i provided in my last comment other wise the name of the country will not appear!

enesdumanli commented 3 years ago

it worked after another try with your example. thank you so much.

VinitBhavsar commented 3 years ago

<CountryPicker onSelect={(country) =>{}} countryCodes excludeCountries={ExcludeCountryCodeList} withCallingCode onClose={() =>{}} flatListProps={{ style: { marginHorizontal: 15 }, showsHorizontalScrollIndicator: false }} visible containerButtonStyle={{opacity: 0}} /> try this prop @enesdumanli