React Native Countries
React Native Countries v1.0.2 will provide you directly native countries list. The names of the countries come in the native language.
Getting Started
Installation
With NPM
npm install --save react-native-countries
With YARN
yarn add react-native-countries
Linking
Automatic linking
react-native link react-native-countries
Manual Linking
Manual Installation for IOS and Android (If something went wrong with react-native link)
With Cocoapods (IOS)
İf you're using Cocoapods you should add this line to your Podfile file
pod 'ReactNativeCountries', :path => '../node_modules/react-native-countries/ios'
Usage
;
This package will provide you 3 different options to getting countries.
getCountryNames
RNCountrygetCountryNames
This constant will provide you only name of countries.
getCountryCodes
RNCountrygetCountryCodes
This constant will provide you only A2 code of countries. (I.E: EN, TR, FR
)
getCountryNamesWithCodes
RNCountrygetCountryNamesWithCodes
This constant will provide you name and code of countries. (I.E: [{code:'TR',name:'Turkey'},{code:'EN', name:'England'}]
)
Sample Usage
;;; { superprops; thisstate = countryCode: "TR" } { let countryNamesWithCodes = RNCountrygetCountryNamesWithCodes; countryNamesWithCodes; this } { return <View style=stylescontainer> <Picker selectedValue=thisstatecountryCode style=stylespicker onValueChange= this> thisstatecountryNameListWithCode </Picker> <Text>Selected Country Code: thisstatecountryCode</Text> </View> }const styles = StyleSheet;
Example
You can find the usage example of the package in the example folder.
git clone https://github.com/talut/react-native-countries cd react-native-countries/example npm install react-native run-ios or android
Thanks
- Thanks to you @cagriyilmaz for IOS part.
License
This project is licensed under the MIT License - see the LICENSE.md file for details