When should I use curly braces for ES6 import?

后端 未结 11 941
借酒劲吻你
借酒劲吻你 2020-11-21 09:46

It seems to be obvious, but I found myself a bit confused about when to use curly braces for importing a single module in ES6. For example, in the React-Native project I am

11条回答
  •  暖寄归人
    2020-11-21 10:37

    • If there is any default export in the file. There is no need to use the curly braces in the import statement.

    • if there is more than one export in the file then we need to use curly braces in the import file so that which are necessary we can import.

    • You can find the complete difference when to use curly braces and default statement in the bellow youtube video.

    https://www.youtube.com/watch?v=tN-SYsGoDYo&t=130s

提交回复
热议问题