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

Codemod to import * as React from "react"; #18102

Merged
merged 2 commits into from
Feb 22, 2020

Conversation

sebmarkbage
Copy link
Collaborator

This is the correct way to import React from an ES module since the ES module will not have a default export. Only named exports.

I'm doing some changes to named exports and this will stop working. For open source ES modules we'll probably publish some default object that warns as an upgrade path but we can't use that in our own code.

This is the correct way to import React from an ES module since the ES
module will not have a default export. Only named exports.
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 22, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@sizebot
Copy link

sizebot commented Feb 22, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against 3be66cf

@sizebot
Copy link

sizebot commented Feb 22, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against 3be66cf

@sebmarkbage
Copy link
Collaborator Author

As far I can tell this didn't change any bytes in the build.

@sebmarkbage sebmarkbage merged commit 0934879 into facebook:master Feb 22, 2020
TrySound added a commit to jquense/react-big-calendar that referenced this pull request Feb 22, 2020
Ref facebook/react#18102

Finally react team officially ditched default import.
TrySound added a commit to TrySound/react-beautiful-dnd that referenced this pull request Feb 22, 2020
Ref facebook/react#18102

Also migrated from `import { type Node } from 'react';` to `React.Node`
as more explicit because `Node` is also DOM type and may conflict when
import is forgotted.
TrySound added a commit to TrySound/material-ui that referenced this pull request Feb 22, 2020
TrySound added a commit to TrySound/svgr that referenced this pull request Feb 23, 2020
TrySound added a commit to TrySound/svgr that referenced this pull request Feb 23, 2020
@NE-SmallTown
Copy link
Contributor

since the ES module will not have a default export. Only named exports

I'm a little bit confused here, as far as I know, ES module has default export, you can find it in MDN or spec, so maybe I miss some thing about this issue context, please correct me if I'm wrong, thanks!

@TrySound
Copy link
Contributor

"React es module will not have default export"

@ghost ghost mentioned this pull request Jan 7, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants