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

【Question】'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. #280

Open
Jairwin-L opened this issue Oct 21, 2020 · 5 comments

Comments

@Jairwin-L
Copy link

Jairwin-L commented Oct 21, 2020

Run :
npx react-codemod update-react-imports

babel version:

"@babel/core": "^7.12.3",
"@babel/preset-react": "^7.12.1",

It report:
image

@cseas
Copy link

cseas commented Nov 21, 2020

I'm getting the same error with TypeScript. The migration guide for the new JSX transforms in React v17 doesn't mention anything about TypeScript and this seems to be a TypeScript error.

My setup:
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-scripts": "4.0.0",

@henryqdineen
Copy link

henryqdineen commented Feb 25, 2021

We ran into this also. You can fix it by setting the jsx compiler option: https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#react-17-jsx-factories

@Jairwin-L
Copy link
Author

We ran into this also. You can fix it by setting the jsx compiler option: https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#react-17-jsx-factories

ok

"jsx": "preserve",

@Jairwin-L Jairwin-L changed the title 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. 【Question】'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. Mar 6, 2021
@chandrarishabh
Copy link

how to use JSX transforms with TypeScript3.9? Any leads?

@cseas
Copy link

cseas commented Jun 16, 2021

If you're talking about the new jsx transform that comes with react v17, that's only supported in TypeScript 4.1+
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#react-17-jsx-factories

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

No branches or pull requests

4 participants