Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 default export/import, named export/import #67

Open
sunmingtao opened this issue Nov 3, 2019 · 1 comment
Open

ES6 default export/import, named export/import #67

sunmingtao opened this issue Nov 3, 2019 · 1 comment

Comments

@sunmingtao
Copy link
Owner

This is the best explanation

https://stackoverflow.com/questions/36795819/when-should-i-use-curly-braces-for-es6-import

But in import React from 'react';, the name of React cannot be changed. Changing to other values will result
'React' must be in scope when using JSX
Why?

@sunmingtao
Copy link
Owner Author

a.js -- not default export
export const a = 42;

b.js -- must use named import (with curly braces)
import {a} from './a'; //Only this works
import {b} from './a'; //Not working

a.js -- default export
export default 42;

b.js -- can use default import (without curly braces)
import a from 42; //works
import b from 42; //also works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant