Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sm-country-info

shoaibsm9ISC1.1.0

A React component package for retrieving country information.

Country information, Geographical data, Nation details, Country statistics, International data, Geo API, World facts, Global insights, Geo components, Country UI

readme

sm-country-info

A React component package for retrieving country information.

Installation

You can install the package via npm:

npm install sm-country-info

## Usage

Example usage in a React component:

import React, { useEffect, useState } from 'react';
import { getCountryInfo } from 'sm-country-info';

const App = () => {
    const [countryInfo, setCountryInfo] = useState(null);

    useEffect(() => {
        const fetchData = async () => {
            try {
                const data = await getCountryInfo('India');
                setCountryInfo(data[0]); // Assuming the API returns an array of countries and we want the first one
            } catch (error) {
                console.error('Error fetching country data:', error.message);
            }
        };

        fetchData();
    }, []);

    return (
        <div>
            <h1>Country Information</h1>
            {countryInfo && (
                <div>
                    <p>Country Name: {countryInfo.name.common}</p>
                    <p>Country Capital: {countryInfo.capital}</p>
                    {/* Add more details as needed */}
                </div>
            )}
        </div>
    );
};

export default App;

NPM Version Badge:

npm version