Skip to main content

Country Whitelist

The whitelist prop on the CountryDropdown component limits the listed countries to those that you specify. The values are found in the countryShortCode value in the source data package. Note the order will always be alphabetical.


import React, { useState } from 'react';
import { CountryDropdown, RegionDropdown } from 'react-country-region-selector';

const CountryWhitelist = () => {
const [country, setCountry] = useState('');
const [region, setRegion] = useState('');

return (
<>
<CountryDropdown
value={country}
onChange={(val) => setCountry(val)}
whitelist={['GB', 'US', 'CA']}
/>
<RegionDropdown
country={country}
value={region}
onChange={(val) => setRegion(val)}
/>
</>
);
};

export default CountryWhitelist;