Posts > default exports vs named export
April 6, 2023
Why export in javascript?
utils
folder is a good way to use exportsYou can export function()
, [array]
, {object}
, class
.
👌You can have named and default export in one source and import them together as well. importData
,{data2, data3}
from./exportFile.js
const data = [
{},
{},
]
export default data;
There’s only one default export per module.
import data from './exportData.js'
export const data = [
{},
{},
]
export const data2 = [
{},
{},
]
can be helpful to export multiple values from one source
import {data, data2} from './exportData.js'