Yummygum / flagpack-core

Flagpack contains 250+ flag icons to easily use within your code project.
https://flagpack.xyz
MIT License
576 stars 131 forks source link

isoToCountryCode function will return JS error in case it can't find country related to isoCode #53

Open jamilalisgandarov opened 3 years ago

jamilalisgandarov commented 3 years ago

Please check all that apply

Expected Behavior

JS error shouldn't break whole application, can return undefined instead of breaking app

Current Behavior

Breaking app in case there is not country related to passed country code

Possible Solution

Issue is here: https://github.com/Yummygum/flagpack-core/blob/55fb55406047321c611b1e8a9738775175b24ee7/index.js#L10 Would be better to check if country has found before trying to get [keyToGet]

Steps to Reproduce

Pass unrelated code or GB for UK

Screenshots

image

Context

I am using flagpack-react to render flags based on country code passed by our end. Looks like we have mismatch for some country alpha 2 codes, but instead of breaking applicaiton, it would be better to return null from the Flag component

Your Environment