Socket
Socket
Sign inDemoInstall

country-react-select

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    country-react-select

React select component for Country, State, City databases. It supports country, state and city dropdown in Reactjs.


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
29.8 kB
Created
Weekly downloads
 

Readme

Source

Country-react-select

The Country State Select control for React.

Features include:

  • Country picker.
  • State picker.
  • City picker.

Installation and usage

yarn add country-react-select

or

npm instal country-react-select --save

Sample code

Country picker:

import React, { useState } from 'react';
import {CountryPicker} from 'country-react-select';

export default function App() {
  const [selectedOption, setSelectedOption] = useState(null);
  return (
    <div className="App">
      <CountryPicker
        value={selectedOption}
        onChange={setSelectedOption}
      />
    </div>
  );
}

CountryPickerProps

  • isDisabled - disable the control
  • isMulti - allow the user to select multiple values
  • onChange - subscribe to change events
  • placeholder - change the text displayed when no option is selected
  • value - control the current value

State picker:

import React, { useState } from 'react';
import {StatePicker} from 'country-react-select';

export default function App() {
  const [selectedOption, setSelectedOption] = useState(null);
  return (
    <div className="App">
      <StatePicker
        value={selectedOption}
        onChange={setSelectedOption}
        country={'CA'}
      />
    </div>
  );
}

City picker:

import React, { useState } from 'react';
import {CityPicker} from 'country-react-select';

export default function App() {
  const [selectedOption, setSelectedOption] = useState(null);
  return (
    <div className="App">
      <CityPicker
        value={selectedOption}
        onChange={setSelectedOption}
        country={'CA'}
        state={'QC'}
      />
    </div>
  );
}

License

MIT Licensed. Copyright (c) Vu Vo 2023.

Keywords

FAQs

Last updated on 21 Feb 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc