react-codemod icon indicating copy to clipboard operation
react-codemod copied to clipboard

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

Open Jairwin-L opened this issue 5 years ago • 5 comments

Run : npx react-codemod update-react-imports

babel version:

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

It report: image

Jairwin-L avatar Oct 21 '20 13:10 Jairwin-L

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",

cseas avatar Nov 21 '20 07:11 cseas

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

henryqdineen avatar Feb 25 '21 02:02 henryqdineen

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 avatar Mar 06 '21 13:03 Jairwin-L

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

chandrarishabh avatar Jun 15 '21 21:06 chandrarishabh

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

cseas avatar Jun 16 '21 16:06 cseas