react-select-country-list
Advanced tools
Comparing version 2.2.2 to 2.2.3
{ | ||
"name": "react-select-country-list", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Maps ISO 3166-1-alpha-2 codes to English country names and match react-select options props", | ||
@@ -5,0 +5,0 @@ "main": "country-list.js", |
@@ -7,3 +7,3 @@ # react-select-country-list | ||
Uses data from http://data.okfn.org/data/country-list | ||
Uses data from https://www.iso.org/iso-3166-country-codes.html | ||
@@ -24,32 +24,19 @@ | ||
```js | ||
import React, { Component } from 'react'; | ||
import React, { useState, useMemo } from 'react' | ||
import Select from 'react-select' | ||
import countryList from 'react-select-country-list' | ||
class CountrySelector extends Component { | ||
constructor(props) { | ||
super(props) | ||
function CountrySelector() { | ||
const [value, setValue] = useState('') | ||
const options = useMemo(() => countryList().getData(), []) | ||
this.options = countryList().getData() | ||
this.state = { | ||
options: this.options, | ||
value: null, | ||
} | ||
const changeHandler = value => { | ||
setValue(value) | ||
} | ||
changeHandler = value => { | ||
this.setState({ value }) | ||
} | ||
return <Select options={options} value={value} onChange={changeHandler} /> | ||
} | ||
render() { | ||
return ( | ||
<Select | ||
options={this.state.options} | ||
value={this.state.value} | ||
onChange={this.changeHandler} | ||
/> | ||
) | ||
} | ||
} | ||
export default CountrySelector | ||
``` | ||
@@ -56,0 +43,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36410
117