0

I have two classes

 class Page1 {
   get abc()  { return $('.btn.success'); }
 }
 export default new Page1();   

and another class

 export default class Page2  {
     function abc() {
     }
  }

And when I import the 2 classes, what should be used. It throws error when I try

`import { Page1} from './page1'`

but works when I try

`import Page1 from './page1'`

But for the other class, when I try

`import Page2 from './page2'`

It throws error and works when I try

 `import {Page2} from './page2'`

What is the difference? TIA

NewUser123
  • 99
  • 9
  • Possible duplicate of [When should I use curly braces for ES6 import?](https://stackoverflow.com/questions/36795819/when-should-i-use-curly-braces-for-es6-import) – CertainPerformance Jul 29 '19 at 00:17
  • The canonical question there should describe the issue, but I don't think you've posted your code verbatim - both of the exporting files use `export default`. You say that the named import works for the `page2` file, but the `page2` file has no named exports. – CertainPerformance Jul 29 '19 at 00:21
  • (Curly braces are used if you would like to import a non-default export.) --> this answer from the duplicate explained it in simple words. Thank you! – NewUser123 Jul 29 '19 at 01:06
  • Duplicate , refer https://stackoverflow.com/questions/48537180/difference-between-import-something-from-somelib-and-import-something-from – Narasimha Prasanna HN Jul 29 '19 at 07:52

0 Answers0