Installations
npm install rn-country-picker-modal
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.16.0
NPM Version
6.9.0
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (82.64%)
JavaScript (17.36%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
19,718
Last Day
1
Last Week
6
Last Month
15
Last Year
221
GitHub Statistics
1,083 Stars
360 Commits
814 Forks
19 Watching
11 Branches
64 Contributors
Package Meta Information
Latest Version
1.0.2
Package Id
rn-country-picker-modal@1.0.2
Size
496.45 kB
NPM Version
6.9.0
Node Version
10.16.0
Publised On
04 Jul 2019
Total Downloads
Cumulative downloads
Total Downloads
19,718
Last day
-66.7%
1
Compared to previous day
Last week
-14.3%
6
Compared to previous week
Last month
114.3%
15
Compared to previous month
Last year
-96.1%
221
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
8
Dev Dependencies
18
The best Country Picker for React Native.
Installation
1$ yarn add react-native-country-picker-modal
Basic Usage
1import DeviceInfo from 'react-native-device-info' 2 3import React, { 4 AppRegistry, 5 Component, 6 StyleSheet, 7 Text, 8 View, 9 StatusBarIOS, 10 PixelRatio 11} from 'react-native' 12import CountryPicker, { 13 getAllCountries 14} from 'react-native-country-picker-modal' 15 16const NORTH_AMERICA = ['CA', 'MX', 'US'] 17 18class Example extends Component { 19 constructor(props) { 20 StatusBarIOS.setHidden(true) 21 super(props) 22 let userLocaleCountryCode = DeviceInfo.getDeviceCountry() 23 const userCountryData = getAllCountries() 24 .filter(country => NORTH_AMERICA.includes(country.cca2)) 25 .filter(country => country.cca2 === userLocaleCountryCode) 26 .pop() 27 let callingCode = null 28 let cca2 = userLocaleCountryCode 29 if (!cca2 || !userCountryData) { 30 cca2 = 'US' 31 callingCode = '1' 32 } else { 33 callingCode = userCountryData.callingCode 34 } 35 this.state = { 36 cca2, 37 callingCode 38 } 39 } 40 render() { 41 return ( 42 <View style={styles.container}> 43 <Text style={styles.welcome}>Welcome to Country Picker !</Text> 44 <CountryPicker 45 countryList={NORTH_AMERICA} 46 onChange={value => { 47 this.setState({ cca2: value.cca2, callingCode: value.callingCode }) 48 }} 49 cca2={this.state.cca2} 50 translation="eng" 51 /> 52 <Text style={styles.instructions}>press on the flag</Text> 53 {this.state.country && ( 54 <Text style={styles.data}> 55 {JSON.stringify(this.state.country, null, 2)} 56 </Text> 57 )} 58 </View> 59 ) 60 } 61} 62 63const styles = StyleSheet.create({ 64 container: { 65 flex: 1, 66 justifyContent: 'center', 67 alignItems: 'center' 68 }, 69 welcome: { 70 fontSize: 20, 71 textAlign: 'center', 72 margin: 10 73 }, 74 instructions: { 75 fontSize: 12, 76 textAlign: 'center', 77 color: '#888', 78 marginBottom: 5 79 }, 80 data: { 81 padding: 15, 82 marginTop: 10, 83 backgroundColor: '#ddd', 84 borderColor: '#888', 85 borderWidth: 1 / PixelRatio.get(), 86 color: '#777' 87 } 88}) 89 90AppRegistry.registerComponent('example', () => Example)
Props
Key | Type | Default | Description |
---|---|---|---|
cca2 | string | *required | code ISO 3166-1 alpha-2 (ie. FR, US, etc.) |
translation | string | 'eng' | The language display for the name of the country (deu, fra, hrv, ita, jpn, nld, por, rus, spa, svk, fin, zho, cym) |
onChange | function | *required | The handler when a country is selected |
onClose | function | *required | The handler when the close button is clicked |
countryList | array | See cca2.json | List of custom CCA2 countries to render in the list. Use getAllCountries to filter what you need if you want to pass in a custom list |
excludeCountries | array | [] | List of custom CCA2 countries you don't want to render |
closeable | bool | false | If true, the CountryPicker will have a close button |
filterable | bool | false | If true, the CountryPicker will have search bar |
filterPlaceholder | string | 'Filter' | The search bar placeholder |
autoFocusFilter | bool | true | Whether or not the search bar should be autofocused |
styles | object | {} | Override any style specified in the component (see source code) |
disabled | bool | false | Whether or not the Country Picker onPress is disabled |
transparent | bool | false | If true, the CountryPicker will render the modal over a transparent background |
animationType | string | 'none' | The handler that controls how the modal animates |
closeButtonImage | React.element | default close button Image | Custom close button Image |
flagType | string | 'emoji' on iOS, 'flat' on Android | If set, overwrites the default OS based flag type. |
hideAlphabetFilter | bool | false | If set to true, prevents the alphabet filter rendering |
renderFilter | Function | undefined | If 'filterable={true}' and renderFilter function is provided, render custom filter component.* |
*
1renderFilter = ({value, onChange, onClose}) => ( 2 <CustomFilterComponent 3 value={value} 4 onChange={onChange} 5 onClose={onClose} 6 /> 7)
Dependencies
- world-countries : https://www.npmjs.com/package/world-countries
FAQ
Is it supported and tested both on android and iOS?
YES
Is the data that is populated inside the list saved offline once I install your package?
YES : It used the world-countries package and image is stored into json and base64.
Tiers lib using this lib
See also
Contribution
- @xcapentier The main author.
Questions
Feel free to contact me or create an issue
made with ♥
Licence
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 11/18 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Reason
27 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-3q56-9cc2-46j4
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More