# react-country-suggest

> React component for country names completion, based on api

Latest version **1.0.1** (published 2018-10-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-country-suggest
pnpm add react-country-suggest
yarn add react-country-suggest
bun add react-country-suggest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-10-18 |
| First published | 2018-10-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| Author | Er Myril |
| Maintainers | shiasyn |

## Links

- npm: https://www.npmjs.com/package/react-country-suggest
- Repository: https://github.com/shiasyn/react-country-suggest
- Homepage: https://github.com/shiasyn/react-country-suggest.git
- Issues: https://github.com/shiasyn/react-country-suggest/issues
- npm.io page: https://npm.io/package/react-country-suggest

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [react](https://npm.io/package/react.md) ^16.5.2
- [react-dom](https://npm.io/package/react-dom.md) ^16.5.2
- [babel-preset-react](https://npm.io/package/babel-preset-react.md) ^6.24.1

## Recent versions

- 1.0.1 (latest) — 2018-10-18
- 1.0.0 — 2018-10-18

## README

# Country Suggest react.js component


![image](https://user-images.githubusercontent.com/11752471/47147073-16135480-d2d6-11e8-8854-40031d9594fb.png)


By default component will use https://restcountries.eu/ API
## Usage 
  ```javascript   
    <CountrySelect 
       apiURL="https://restcountries.eu/rest/v2/name/"
       nameField="name" 
       flagField="flag" 
       dataCallback={callback}
    />,

  ```
## Parameters
| Property      | Default value                          | Description                                        | 
| ------------- |:--------------------------------------:| -------------------------------------------------- |
| apiURL        | https://restcountries.eu/rest/v2/name/ | url for getting data, user's input will be appended to the end of a string |
| nameField     | "name"                                 | name of field with country name in the returned json object.    |
| flagField     | "flag"                                 | name of field with link to flag icon in the returned json object|
| dataCallback  | "null"                                 | callback function for modification of data from response        |

### dataCallback
Callback function takes single object from collection of data recieved from API, and should return an object with name and flag properties.

Here is an example of a callback function that uses nativeName property instead of name, and shiny flags from  https://www.countryflags.io/

```javascript   
  var callback = function dataManage(resp){
    let data = {
      name: resp.nativeName,
      flag: "https://www.countryflags.io/" + resp.alpha2Code + "/shiny/64.png",
    }
    return data;
  }
  
  ...
  
  <CountrySelect dataCallback={callback} />,
  
```

---
_Source: https://npm.io/package/react-country-suggest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
