简体   繁体   中英

react native, how to show flag in react-native-country-picker-modal

I'm using react-native-country-picker-modal and I want to show flag when user select a country. But it's not rendering on screen. Anyone can tell me how to render flag? below is my code

//function to set flag
const countryChange = ({ flag}) => {
    setState(state => ({
      ...state,
      flag: flag,
    }));
  };
....
 <Image
   source={{uri: flag}}
   style={{tintColor: colors.blackColor, width: 28, height: 20}}
   />
....
   <CountryPicker
      cca2={cca2}
      visible={countryPickerModalVisible}
      withFlagButton={true}
      withFilter
      onClose={onCountryPickerModalClose}
      onSelect={countryChange}
      withFlag
    />
const [withCallingCode, setWithCallingCode] = useState<boolean>(true)
const [withAlphaFilter, setWithAlphaFilter] = useState<boolean>(true)
const [withFilter, setwithFilter] = useState<boolean>(true)
const [countryCode, setCountryCode] = useState('US')
const [visible, setVisible] = useState(false)

<CountryPicker
{...{
    countryCode,
    withCallingCode,
    withAlphaFilter,
    withFilter,
    onSelect,
}}
modalProps={{
    visible: visible
}}
onOpen={() => setVisible(true)}
onClose={() => setVisible(false)} />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM