Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-select-country-list
Advanced tools
Maps ISO 3166-1-alpha-2 codes to English country names and match react-select options props
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
npm install react-select-country-list --save
or
yarn add react-select-country-list
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
All input is case-insensitive.
Expects the English country name.
Returns the code for that country.
If not found, it returns undefined
.
Expects a two-digit country code.
Returns the name for that country.
If not found, it returns undefined
.
Returns an array of all country codes.
Returns an array of all country names.
Returns a key-value object of all countries using the code as key.
Returns a key-value object of all countries using the name as key.
Returns an array of all country information, in the same format as it gets imported.
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.
// Make 'Viet Nam' -> 'Vietnam'
countries.setLabel('VN', 'Vietnam').getLabel('VN') // 'Vietnam'
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.
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'
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
countries.native().getLabel('TW') // 臺灣
MIT
FAQs
Maps ISO 3166-1-alpha-2 codes to English country names and match react-select options props
We found that react-select-country-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.