Reputation: 11285
I am fairly new to ES6.
I am trying to call a function with two arguments:
export XYZ withFetching(noticeAPI)(promoIter)
and
export withFetching(noticeAPI)(promoIter)
It works when I do it as:
export default withFetching(noticeAPI)(promoIter)
The function looks like this:
const withFetching = (url) => (Comp) =>
Why does it work with the default keyword but not with any type of names?
Sorry if this is a dumb question about ES6, but I've tried every variation of the export syntax that I found on here with no luck.
https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export
Upvotes: 1
Views: 78
Reputation: 161457
export default withFetching(noticeAPI)(promoIter);
is short for
const _invisibleVariable_ = withFetching(noticeAPI)(promoIter);
export { _invisibleVariable_ as default };
So given your example
export XYZ withFetching(noticeAPI)(promoIter)
assuming you want XYZ
to be the name, you can do
const XYZ = withFetching(noticeAPI)(promoIter);
export { XYZ };
or
export const XYZ = withFetching(noticeAPI)(promoIter);
Upvotes: 1
Reputation: 166
Hi did you try like this ?
export const XYZ = withFetching(noticeAPI)(promoIter);
And then importing it like this
import { XYZ } form 'somepath';
Upvotes: 0