Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-select-country-list

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-select-country-list

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

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
increased by2.03%
Maintainers
1
Weekly downloads
 
Created
Source

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 http://data.okfn.org/data/country-list

js-standard-style

Example

import React, { Component } from 'react';
import Select from 'react-select'
import countryList from 'react-select-country-list'

class CountrySelector extends Component {
  constructor(props) {
    super(props)

    this.options = countryList().getData()

    this.state = {
      options: this.options,
      value: null,
    }
  }

  changeHandler = value => {
    this.setState({ value })
  }

  render() {
    return (
      <Select
        options={this.state.options}
        value={this.state.value}
        onChange={this.changeHandler}
      />
    )
  }
}

Methods

Usage:

import countryList from 'react-select-country-list';

All input is case-insensitive.

getValue(code)

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

getLabel(name)

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

getValues()

Returns an array of all country names.

getLabels()

Returns an array of all country codes.

getValueList()

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

getLabelList()

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

getData()

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

Use with

Install

npm install react-select-country-list

License

MIT

Keywords

FAQs

Package last updated on 30 Jul 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc