react-countries
v1.1.1
Published
A tiny fully customizable react hook which gives you full list of countries with their name, dial code, alpha-2 code and flag emoji.
Downloads
240
Maintainers
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.
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