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

Could you add some info as to how to use it with React JS? #66

Open
nonopolarity opened this issue Mar 31, 2017 · 2 comments
Open

Could you add some info as to how to use it with React JS? #66

nonopolarity opened this issue Mar 31, 2017 · 2 comments

Comments

@nonopolarity
Copy link

nonopolarity commented Mar 31, 2017

the full question on: http://stackoverflow.com/questions/43144036/in-react-how-to-convert-country-code-to-country-name-using-country-data

It is:

I thought I could do

npm install --save country-data

and then in the code:

import CountryData from "country-data";

and use

CountryData.countries["TW"]

to get the country data, and

CountryData.countries["TW"].name

to get the name. But CountryData.countries["TW"] gets undefined already. How can it be done?

@gregaubert
Copy link

Are you using webpack with your react project ? Maybe here is the solution : https://github.com/OpenBookPrices/country-data#using-with-webpack

@evdb
Copy link
Member

evdb commented Apr 21, 2017

This is odd. Please could you create a test case that fails that I can look at. Your use case is so simple it should work, so I think it must be something in the React setup that is causing trouble. I've no experience with that.

Use an online code bin or better yet fork the repo and create a failing test case (if that is possible).

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

No branches or pull requests

3 participants