I want to export some module like below way but always failed..
foo.js
const foo = {
a: 'b'
};
export default foo;
index.js
export foo from './foo'; // encounter error here
export * from './foo'; // it works..
I don't know why can't I use the first method to export module from foo.js
, in my opinion, I can export anything like func, class, variables etc..
To export a default export of one module as a named export of another you must do:
// index.js
export { default as foo } from './foo';
You can now import foo
as a named export elsewhere:
// another.js
import { foo } from './index'
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