1.0.0 • Published 3 years ago

react-use-country-region v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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