Open nonopolarity opened 7 years ago
Are you using webpack with your react project ? Maybe here is the solution : https://github.com/OpenBookPrices/country-data#using-with-webpack
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).
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?