react-country-dropdown

1.1.1 • Public • Published

react-country-dropdown

A simple dropdown menu for selecting countries

npm

Screenshot from 2023-03-25 12-43-36

Install

npm install --save react-country-dropdown

Usage

import React, { Component } from 'react'

import { ReactCountryDropdown } from 'react-country-dropdown'
import 'react-country-dropdown/dist/index.css'

const Example = () => {
  const handleSelect = (country) => {
    console.log(country)
    /* returns the details on selected country as an object
    	{
          name: "United States of America", 
          code: "US", 
          capital: "Washington, D.C.", 
          region: "Americas", 
          latlng: [38, -97]
        }
    */
  }
  return (
    <div>
      <ReactCountryDropdown onSelect={handleSelect} countryCode='IN' />
    </div>
  )
}

(If you dont select set a default country with "countryCode" ; Then by default the selected country will US.)

License

MIT © RocktimSaikia

Package Sidebar

Install

npm i react-country-dropdown

Weekly Downloads

542

Version

1.1.1

License

MIT

Unpacked Size

40.8 kB

Total Files

10

Last publish

Collaborators

  • rocktimsaikia