react-use-country-region
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-use-country-region

NPM JavaScript Style Guide

A simple react hook to display a country regions. Use with any UI Framework (Material UI) or any Headless UI (React Aria, Reach UI, etc) Uses country-region-data package dependencies to provide (latest) data.

Install

yarn add react-use-country-region

Usage

Get list of countries

To get list of available countries

import { useCountryRegion } from 'react-use-country-region';

const Example = () => {
  const { getCountryList } = useCountryRegion();
  const data = getCountryList();

  return <div>{JSON.stringify(data)}</div>;
};

Get list of regions

Simply pass a valid ISO country code to get regions/state/provice data

import { useCountryRegion } from 'react-use-country-region';

const Example = () => {
  const { result } = useCountryRegion('MY');
  return <div>{JSON.stringify(result.regions)}</div>;
};

License

MIT © MistaPidaus

Readme

Keywords

none

Package Sidebar

Install

npm i react-use-country-region

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

382 kB

Total Files

33

Last publish

Collaborators

  • pidaus