diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f92145..2e18f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Fixed undefined country list + ## [0.15.0] - 2021-04-26 ### Added diff --git a/react/LocationCountry.tsx b/react/LocationCountry.tsx index d0e9496..9503380 100644 --- a/react/LocationCountry.tsx +++ b/react/LocationCountry.tsx @@ -60,7 +60,7 @@ const LocationCountry: React.FC = ({ const [country, setCountry] = useState(useCountry()) - if (country && countries && !countries.includes(country)) { + if (country && countries && countries.length > 0 && !countries.includes(country)) { throw new Error( `The country "${country}" doesn't belong to the country list, can't render LocationCountry` ) @@ -84,7 +84,7 @@ const LocationCountry: React.FC = ({ }, [country, setAddress]) // Do not render anything if we only have 1 country or none. - if (countries.length <= 1) { + if ((countries ?? []).length <= 1) { return null }