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

How to show flag button? #326

Closed 15110011 closed 4 years ago

15110011 commented 4 years ago

Issue Description

I tried to use withFlagButton but It still don't show any flag icon or image

Steps to Reproduce / Code Snippets

<CountryPicker onSelect={value => { onSelect(value); }} cca2={cca2} translation="eng" withFlag withCallingCode visible withFlagButton={withFlagButton} withFilter placeholder="" withEmoji />

ispulkit commented 4 years ago

Getting the same issue

ispulkit commented 4 years ago

Found a hacky workaround until this gets solved. Use the useState hook in your component to store the countryCode. Show the flag additionally using:

import CountryPicker, {FlagButton} from 'react-native-country-picker-modal';

   <FlagButton withEmoji={true} countryCode="US" />
<CountryPicker
                  onSelect={onCountrySelect}
                  withEmoji={true}
                  withFlag={true}
                  withFlagButton={true}
                />

Tweak the flagButton onPress for your desired behaviour (open/close modal).

15110011 commented 4 years ago

@ispulkit Its a component instead of props? its different from the docs and examples. btw, thank you @ispulkit

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tushar2004 commented 4 years ago

Hi, Just pass in countryCode as a prop and it should work just fine. <CountryPicker countryCode={'FR'} withFlag withCountryNameButton withAlphaFilter withCallingCode onSelect={() => { // do something }} />

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.