All Projects → Chun-Lin → react-select-country-list

Chun-Lin / react-select-country-list

Licence: MIT license
This is the country list data format for react-select

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-select-country-list

Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (+150%)
Mutual labels:  country
Laravel Location
A simple Laravel Package to sort Countries, States and Cities
Stars: ✭ 162 (+305%)
Mutual labels:  country
Nager.Country
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
Stars: ✭ 68 (+70%)
Mutual labels:  country
Geo ip
Retreive the geolocation of an IP address based on the ipinfodb.com webservice
Stars: ✭ 103 (+157.5%)
Mutual labels:  country
Circle Flags
A collection of 300+ minimal circular SVG country flags
Stars: ✭ 139 (+247.5%)
Mutual labels:  country
iso-3166-1
🇳🇴  Lookup information with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3 and ISO 3166-1 numeric
Stars: ✭ 51 (+27.5%)
Mutual labels:  country
M0b Tool
exploit
Stars: ✭ 68 (+70%)
Mutual labels:  country
web-coronavirus-stats
🌎 🦠 😷 Coronavirus disease (COVID-2019) global / world / country statistics and reports
Stars: ✭ 2 (-95%)
Mutual labels:  country
Covid19radar
Open Source / i18n / iOS Android Cross Platform Contact Tracing App by exposure notification framework Xamarin App and Server Side Code
Stars: ✭ 35 (-12.5%)
Mutual labels:  country
csc picker
A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.
Stars: ✭ 25 (-37.5%)
Mutual labels:  country
Smartmaterialspinner
The powerful android spinner library for your application
Stars: ✭ 108 (+170%)
Mutual labels:  country
Nkvphonepicker
An UITextField subclass to simplify country code's picking. Swift 5.0
Stars: ✭ 131 (+227.5%)
Mutual labels:  country
react-power-select
A highly composable & reusable select/autocomplete components
Stars: ✭ 63 (+57.5%)
Mutual labels:  react-select
Awesome Open Source By Country Or Region
Lists of open source projects mainly made by devs of a country or region.
Stars: ✭ 102 (+155%)
Mutual labels:  country
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-17.5%)
Mutual labels:  react-select
Laravel Country State
A helper to list countries & states in English in Laravel 5.1+
Stars: ✭ 77 (+92.5%)
Mutual labels:  country
Laravel World
provide countries, states, and cities relations and database.
Stars: ✭ 222 (+455%)
Mutual labels:  country
Country
Country gives a list of countries with all their flags.
Stars: ✭ 26 (-35%)
Mutual labels:  country
PhoneCountryCodePicker
An iOS tableview picker for PhoneCountryCode (English & Chinese supported)
Stars: ✭ 31 (-22.5%)
Mutual labels:  country
CoronaCord
Discord bot that displays the latest coronavirus statistics. Currently serving over 5,000 communities on Discord.
Stars: ✭ 23 (-42.5%)
Mutual labels:  country

react-select-country-list

This package take country-list as reference, and make it more friendly to react-select

Maps ISO 3166-1-alpha-2 codes to English country names and match react-select options props.

Uses data from https://www.iso.org/iso-3166-country-codes.html

Install

npm install react-select-country-list --save

or

yarn add react-select-country-list

Example

import React, { useState, useMemo } from 'react'
import Select from 'react-select'
import countryList from 'react-select-country-list'

function CountrySelector() {
  const [value, setValue] = useState('')
  const options = useMemo(() => countryList().getData(), [])

  const changeHandler = value => {
    setValue(value)
  }

  return <Select options={options} value={value} onChange={changeHandler} />
}

export default CountrySelector

Methods

All input is case-insensitive.

getValue(label)

Expects the English country name. Returns the code for that country. If not found, it returns undefined.

getLabel(value)

Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.

getValues()

Returns an array of all country codes.

getLabels()

Returns an array of all country names.

getValueList()

Returns a key-value object of all countries using the code as key.

getLabelList()

Returns a key-value object of all countries using the name as key.

getData()

Returns an array of all country information, in the same format as it gets imported.

setLabel(value, label)

Due to different perspectives among different regions, this method can help developers customize the label of specific country. What's more, it can be chained with another methods above.

Usage

// Make 'Viet Nam' -> 'Vietnam'
countries.setLabel('VN', 'Vietnam').getLabel('VN') // 'Vietnam'

setEmpty(label)

You may want an empty value option in the list, so here's the helper function for you. Again, it can be chained with another methods above.

Usage

countries.setEmpty('Select a Country').getLabel('') // 'Select a Country'

We can even chain setLabel and setEmpty together to have list with an empty option and the modified label.

countries.setLabel('VN', 'Vietnam').setEmpty('Select a Country').getLabel('VN') // 'Vietnam'

native()

You may want to display native name of countries, this is the method for you. The data source of native names can be found here

Usage

countries.native().getLabel('TW') // 臺灣

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].