0

In my app, I have a huge constant array of string defined in allCurrency.js file as follows. The real array is much longer than the given array. I import it in my App.js file as import currecyData from './allCurrency'. There is no syntax error. I can't access it in App.js. Just a warning import currecyData from './allCurrency'. How do I access in App.js. I don't want to bring the whole constant array in App.js. It will work, but it will be ugly.

const currecyData = [
    "AED",
    "ARS",
    "AUD",
    "BGN",
    "BRL",
    "BSD",
    "CAD",
    "CHF",
    "CLP",
    "CNY",
    "COP",
    "CZK",
    "DKK",
    "DOP",
    "EGP",
    "EUR",
    "FJD",
    "GBP"]
1
  • 3
    did you do export default currecyData ? Commented Feb 16, 2020 at 8:27

2 Answers 2

1

Either do an

export const currecyData = [
    "AED",
    "ARS",
    "AUD",
    "BGN",
    "BRL",
    "BSD",
    "CAD",
    "CHF",
    "CLP",
    "CNY",
    "COP",
    "CZK",
    "DKK",
    "DOP",
    "EGP",
    "EUR",
    "FJD",
    "GBP"]

And import it as

import {currecyData} from './allCurrency'

or add a default export in your allCurrency.js as obiwankenoobi commented:

export default currecyData;
Sign up to request clarification or add additional context in comments.

Comments

0
    const currecyData = [
"AED",
"ARS",
"AUD",
"BGN",
"BRL",
"BSD",
"CAD",
"CHF",
"CLP",
"CNY",
"COP",
"CZK",
"DKK",
"DOP",
"EGP",
"EUR",
"FJD",
"GBP"];export default currecyData;

You have to export the entity to import it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.