Socket
Socket
Sign inDemoInstall

react-country-region-selector

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-country-region-selector

A simple, configurable React component that lets you add a country dropdown that automatically updates a corresponding region dropdown in your forms.


Version published
Weekly downloads
74K
increased by2.19%
Maintainers
1
Weekly downloads
 
Created
Source

React-Country-Region-Selector

Incomplete! This isn't finished yet.

Demo

You can see it in action here: [...]

Installation

Depending on your setup, pick one of the following.

  1. Installing via npm
npm install react-country-region-selector --save
  1. Use Bower
bower install react-country-region-selector 
  1. Alternatively, you can just use the UMD version of the file. That'll work for AMD, CommonJS or just plain old non-namespaced JS code. For the latter, it'll expose a window.rsrc object.

The scripts only dependency is React (tested with 15.0.1, but should work on earlier versions).

Usage

Using it is really simple. Here are a few examples in a few of the more common formats JS is taking.

  • AMD Example
  • CommonJS Example
  • ES6 with JSX Example
  • ES6 Example
AMD Example
define([
    'react',
    'react-country-region-selector'
], function (React, rcrs) {

    var CountryDropdown = rcrs.CountryDropdown;
    var RegionDropdown = rcrs.CountryDropdown;

});

CommonJS example
ES6 with JSX example
import { CountryDropdown, RegionDropdown } from 'react-country-region-selector';


class Example extends React.Component {
  constructor (props) {
    super(props);
    this.state = { country: '', region: '' };
  }

  selectCountry (val) {
    this.setState({ country: val });
  }

  selectRegion (val) {
    this.setState({ region: val });
  }

  render () {
    const { country, region } = this.state;
    return (
      <div>
        <CountryDropdown
          value={country}
          onChange={(val) => this.selectCountry(val)} />
        <RegionDropdown
          country={country}
          value={region}
          onChange={(val) => this.selectRegion(val)} />
      </div>
    );
  }
}
ES6 example

Options

<CountryDropdown />

ParameterRequired?TypeDescription
valueYesstringThe currently selected country.
onChangeYesFunctionCallback that gets called when the user selects a country.

<RegionDropdown />

ParameterRequired?TypeDescription
countryYesstringThe currently selected country option value.
valueYesstringThe currently selected region option value.
onChangeYesFunctionCallback that gets called when the user selects a region.

Changelog

  • 0.1.0 - Under development.

License

MIT.

Keywords

FAQs

Package last updated on 18 Jun 2016

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