Difference between export {sayHi} from ‘./say.js’ and export {default as sayHi} from ‘./say.js’?
Doesn't the first statement rename default to sayHi just like the second one?
Also are these statements valid? If not why?
- export foo as default from ‘bar.js’
- export foo as newFooName from ‘bar.js’
export {sayHi} from './say.jsdoes. The syntax seems a little misleading to me and I have been struggling to find answersexport {sayHi} from ...is similar toimport {sayHi}. The file that you're importing from must have a named export (not default) with the explicitsayHiname likeexport function sayHi(). Theexport {sayHi} from ...importssayHiby name and re-exports it with the same name. So no, they are not equivalent.export { } from ...with braces means that we are importing something that was a default export imgur.com/a/F2dRPVmdefaultkeyword to get the default thing.