useTelephoneCountryCodes
A hook to provide a list of telephone country codes as an array of strings.
Import
import { useTelephoneCountryCodes } from '@krakentech/utils';Usage
Return all country codes
const { telephoneCountryCodes } = useTelephoneCountryCodes();Include
Return only France and Spain country codes
const { telephoneCountryCodes } = useTelephoneCountryCodes({
include: ['FRA', 'ESP'],
});Exclude
Returns all country codes except France
const { telephoneCountryCodes } = useTelephoneCountryCodes({
exclude: ['FRA'],
});Args
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
include | The country codes to include in the returned dataset | string[] (string to be ISOAlpha3 value) | false | |
exclude | The country codes to exclude from the returned dataset | string[] (string to be ISOAlpha3 value) | false |
Returns
| Name | Type | Description | Example |
|---|---|---|---|
| telephoneCountryCodes | string[] | An array of country codes alongside the country name: eg | ['+33 France', '+34 Spain', ...] |
Notes
- The dataset that powers this hook has been sourced from this link 🔗
- The dataset has been adjusted slightly to suit our needs
Last updated on