Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add country code in each Country object #91

Closed
philippeauriach opened this issue Jul 1, 2021 · 3 comments
Closed

Add country code in each Country object #91

philippeauriach opened this issue Jul 1, 2021 · 3 comments

Comments

@philippeauriach
Copy link

philippeauriach commented Jul 1, 2021

Use case for the feature

Currently countries are listed in key/values with the country code being used as key, but not present in the value object.
This leads to problems when, for example, allowing a user to choose from a list of countries, it is easy to get all countries using Object.values, but then each value does not have its own code.

I would love to make a PR, but don't know where to start? I think we could just update the script (not the data file), to map over all entries just to include the code.

@dmythro
Copy link
Member

dmythro commented Jul 1, 2021

Hi @philippeauriach. Feel free to use Object.entries() for that kind of loops. Otherwise Country objects will get bigger in size.

@dmythro dmythro closed this as completed Jul 1, 2021
@philippeauriach
Copy link
Author

Yes but then, later, we handle just a Country object without the code, otherwise we need to reconstruct a new object from the country and code prop. Seems overkill for a simple property that won't take that much of size in my opinion.
But ok thanks anyway

@dmythro
Copy link
Member

dmythro commented Jul 4, 2021

@philippeauriach it makes total sense, have it in my list as well. But thinking rather on a getter that returns an object of a Country class, with code and maybe some additional features in future. Need to finish that TypeScript migration already. Mainly, not merging that because have doubts on some future structures. You may check the PR #83 as well, by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants