data.shop.shipsToCountries is larger than COUNTRY_CODE
davidkong0987 opened this issue · comments
davidkong0987 commented
this solution works for now
const shipsToCountries = data.shop.shipsToCountries.filter(x=>Object.keys(COUNTRY_CODE).includes(x))
useEffect(() => {
if (data) {
let countryCodes: Array<CountryCode> = [];
console.log(shipsToCountries)
if (searchCountry === '') {
countryCodes = shipsToCountries;
} else {
countryCodes = shipsToCountries.filter((item) =>
COUNTRY_CODE[item].includes(searchCountry),
);
}
setCountryList(countryCodes);
}
}, [data, searchCountry]);