You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The website carefully avoids mentioning how the "react" module should be imported, import React from … or import * as React from …. None of the code examples (that I was able to find) contain the import statement. Both import forms are used in the wild, but our tools disagree which one is correct:
The React source uses a default export, so the first form will become correct once React decides to provide the code as ES6 modules.
TypeScript declarations currently want you to use the second form, but you can enable a compiler option (allowSyntheticDefaultImports ) to allow it to accept the first form, for compatibility with CommonJS modules.
Flow recommends using the second form, but also allows the first form in some cases.
While I don't particularly care which form React decides on (though I dislike the default export because it makes it impossible to treeshake the module), it would be nice to document the "correct" way, so that we can already now prepare for the transition to React-as-true-ES-module.
The text was updated successfully, but these errors were encountered:
The website carefully avoids mentioning how the "react" module should be imported,
import React from …
orimport * as React from …
. None of the code examples (that I was able to find) contain theimport
statement. Both import forms are used in the wild, but our tools disagree which one is correct:While I don't particularly care which form React decides on (though I dislike the default export because it makes it impossible to treeshake the module), it would be nice to document the "correct" way, so that we can already now prepare for the transition to React-as-true-ES-module.
The text was updated successfully, but these errors were encountered: