react-native country picker
npm install react-native-country-picker-modal| iOS | Android | Web |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
|
|
- 🎉 GO TO WEB DEMO 🎉
- snack example
``bash`
$ yarn add react-native-country-picker-modal
For more complete example open App.tsx
`tsx
import React, { useState } from 'react'
import { View, Text, StyleSheet, PixelRatio, Switch } from 'react-native'
import CountryPicker from 'react-native-country-picker-modal'
import { CountryCode, Country } from './src/types'
const styles = StyleSheet.create({
// ...
})
export default function App() {
const [countryCode, setCountryCode] = useState
const [country, setCountry] = useState
const [withCountryNameButton, setWithCountryNameButton] = useState
false,
)
const [withFlag, setWithFlag] = useState
const [withEmoji, setWithEmoji] = useState
const [withFilter, setWithFilter] = useState
const [withAlphaFilter, setWithAlphaFilter] = useState
const [withCallingCode, setWithCallingCode] = useState
const onSelect = (country: Country) => {
setCountryCode(country.cca2)
setCountry(country)
}
return (
title='With country name on button'
value={withCountryNameButton}
onValueChange={setWithCountryNameButton}
/>
title='With emoji'
value={withEmoji}
onValueChange={setWithEmoji}
/>
title='With filter'
value={withFilter}
onValueChange={setWithFilter}
/>
title='With calling code'
value={withCallingCode}
onValueChange={setWithCallingCode}
/>
title='With alpha filter code'
value={withAlphaFilter}
onValueChange={setWithAlphaFilter}
/>
countryCode,
withFilter,
withFlag,
withCountryNameButton,
withAlphaFilter,
withCallingCode,
withEmoji,
onSelect,
}}
visible
/>
{country !== null && (
)}
)
}
`
- countryCode: CountryCoderegion?
- :Regionsubregion?
- : SubregioncountryCodes?
- : CountryCodetheme?
- : Themetranslation?
- : TranslationLanguageCodemodalProps?
- : ModalPropsfilterProps?
- : CountryFilterPropsflatListProps?
- : FlatListPropswithAlphaFilter?
- : booleanwithCallingCode?
- : booleanwithCurrency?
- : booleanwithEmoji?
- : booleanwithCountryNameButton?
- : booleanwithCurrencyButton?
- : booleanwithCallingCodeButton?
- : booleanwithFlagButton?
- : booleanwithCloseButton?
- : booleanwithFilter?
- : booleanwithFlag?
- : booleanwithModal?
- : booleanvisible?
- : booleancontainerButtonStyle?
- : StyleProprenderFlagButton?
- (props: (FlagButton['props'])): ReactNode (FlagButton props)renderCountryFilter?
- (props: CountryFilter['props']): ReactNode (CountryFilter props is TextInputProps)onSelect
- (country: Country): void (Country)onOpen
- (): voidonClose
- (): voidcloseButtonImage?
- : ImageSourcePropTypecloseButtonStyle?
- : StylePropcloseButtonImageStyle?
- : StylePropdisableNativeModal?
- : boolean (you have to wrap your all app with CountryModalProvider)preferredCountries
- : CountryCode preferred countries they appear first (withAlphaFilter must be false)

A simple example to display a CountryPicker component with a dark theme.
`tsx
import CountryPicker, { DARK_THEME } from 'react-native-country-picker-modal'
const MyDarkView = () =>
``
- world-countries : https://www.npmjs.com/package/world-countries
YES
YES : It used the world-countries package and image is stored into json and base64.
- react-native-phone-verification
- @xcapentier The main author.
Feel free to contact me or create an issue
> made with ♥
Looking for a ReactNative freelance expert with more than 12 years experience? Contact me from my website!