Reputation: 2950
Say I have class Panels and class Panel in my ui.
I want to avoid multiple statements such as import Panel.. and import Panels ...
every time I decide to use them.
Instead, I want to re-export Panel from Panels once, and in my app just say something like import * from 'Panels.js'
causing both Panel and Panels appear in the scope of my App.
Is this possible? Good tutorial on the subject? thanks.
Upvotes: 2
Views: 70
Reputation: 5010
You can import several things from the same module like so:
import { Thing1 , Thing2 } from "module-name";
Or import everything like so:
import * as everything from "module-name";
For all other variations see: https://developer.mozilla.org/sv-SE/docs/Web/JavaScript/Reference/Statements/import
Upvotes: 1
Reputation: 62676
You can use import * as Panels from 'Panels';
Inside your code you should use Panels.Panel
and Panels.Panels
Don't forget that you need to
export
both in order toimport
them
Upvotes: 2