2

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.

1
  • You can add the javascript tag to the question, it's relevant Commented Aug 17, 2017 at 21:22

2 Answers 2

2

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 to import them

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

it is important to note that the first option uses ES6 feature destructuring

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.