1.1.1 • Published 9 months ago

react-countries v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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,
}
PropertyTypeDescription
namestring
flagstring
codestring
dial_codestring

Authors

License

MIT © hirenkvaghasiya