Détail du package

react-countries

hirenkvaghasiya95MIT1.1.1

A tiny fully customizable react hook which gives you full list of countries with their name, dial code, alpha-2 code and flag emoji.

country, countries, country list, country dial code list

readme

react-countries

A tiny fully customizable react hook which gives you full list of countries with their name, dial code, alpha-2 code and flag emoji.

NPM JavaScript Style Guide

Install

  • npm
npm install --save react-countries
  • yarn
yarn add react-countries

Usage

A simple example of a component which you can copy-paste and take info about all countries.

import { useCountries } from 'react-countries'

const App = () => {
  const { countries } = useCountries()

  return (
    <>
      <ul>
        {countries.map(
          ({
            name,
            dial_code,
            code,
            flag
          }) => (
            <li key={name}>{flag + " " + name + " | " + code + " (" + dial_code + ")"}</li>
          )
        )}
      </ul>
    </>
  );
}

API

  • Country interface
type country = {
  name: string,
  flag: string,
  code: string,
  dial_code: string,
}
Property Type Description
name string
flag string
code string
dial_code string

Authors

License

MIT © hirenkvaghasiya