Reputation: 1378
if I have two arrays how do I export them for example:
const a=['a','b','c']
const b=['1','2','3']
export default a,b?
Upvotes: 1
Views: 2824
Reputation: 9652
Try the following while exporting:
const arr1 = ['a','b','c']
const arr2 = ['1','2','3']
export default { a, b }
And while importing
import { arr1, arr2 } from "path to the file";
//your code
Upvotes: 5
Reputation: 91
I did it like this:
const a=[1,2,3,];
const b=[4,5,6];
const c=[7,8,9];
export default a;
export { b, c };
Then you import it with:
import a, {b, c} from "./pathToTheFile.js"
If there is a specific situation were you want to import only B and C just do this:
import { b, c } from "./pathToTheFile.js"
Upvotes: 0
Reputation: 1249
export const a=['a','b','c']
export const b=['1','2','3']
//Import page
import { a } from "path/to/a";
import { b } from "path/to/b";
export const foo = "This is not default export"
from each file you can have max 1 default export, but as many not default as you want. Just the import syntaxt is different
Upvotes: 2