Is this valid javascript? It does not error, and appears to work.
export {default as Chooser} from "./chooser";
My interpretation is:
import
thedefault
from"./chooser"
export
the result from #1as Chooser
Is this what is happening?
Is this valid javascript? It does not error, and appears to work.
export {default as Chooser} from "./chooser";
My interpretation is:
import
the default
from "./chooser"
export
the result from #1 as Chooser
Is this what is happening?
Is this valid JavaScript?
Yes.
Is this what is happening?
Yes.
Your interpretation is correct.
import
thedefault
from"./chooser"
This is correct. The default thing being exported is Chooser
and on import, you must use the name given to it with as ...
:
import { Chooser } from "./chooser";
export
the result from #1 asChooser
This is also correct. The name Chooser
is giving the default a new name and exporting it.
Let me break this down:
export {
default as Chooser
} from "./chooser";
What this does is specify the file from which it is exported, and default as Chooser
exports the default under the name Chooser
. Now, on import:
import { Chooser } from "./chooser";
You must specify Chooser
to import because you've essentially named the default.