I am currently working on a react meteor project.
I didn't find any clear documentation when to exactly use export default
and when export const
.
Any opinions on this respectively when to use what and what are the differences?
export default
exports your module with no name, you can thus import it with this syntax :
export default MyModule = () => console.log('foo')
import MyModule from './MyModule' //it works
import foobar from './MyModule' //it also works,
export const
exports with name :
export const MyModule = () => console.log('foo')
import MyModule from './MyModule' //returns empty object since there is no default export
import { MyModule } from './MyModule' //here it works because by exporting without 'default' keyword we explicitly exported MyModule
export default
.export const
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With