'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686)
See original GitHub issueCurrent Behavior
I suddenly started to receive the error below in some of my components.
'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686)
Expected behavior
No errors are displayed.
Suggested solution(s)
A temporary workaround is adding “import React from ‘react’” on the top of the file. Changing the VSCode typescript version does not work. Adding jsx: “react-dev” to tsconfig.json breaks tsdx build process.
Your environment
System:
OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 7.26 GB / 15.51 GB
Container: Yes
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
Browsers:
Chrome: 103.0.5060.114
Firefox: 93.0
npmPackages:
tsdx: ^0.14.1 => 0.14.1
typescript: ^4.6.2 => 4.7.4
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
'React' refers to a UMD global, but the current file is a module
'React' refers to a UMD global, but the current file is a module · "I know with this new version you don't have...
Read more >React refers to UMD global, but the current file is a module
To solve the error "'React' refers to a UMD global, but the current file is a module. Consider adding an import instead", update...
Read more >React' refers to a UMD global, but the current file is a module ...
This error message comes from TypeScript compiler. The React 17 new jsx transform is not currently supported in Typescript 4.0, and will be...
Read more >angular/angular-cli - Gitter
Error:(54, 33) TS2686:'fabric' refers to a UMD global, but the current file is a module. Consider adding an import instead.
Read more >Documentation - Global: Plugin - TypeScript
The same footnote applies to these modules. If your module is not callable or constructable, use the module.d.ts file. Module Plugin or UMD...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved it by importing React manually in all story files.
Unfortunately… 😞
You can set the ts version of tsdx to 4.4 or afterwards. hopefully new version will upgrade the ts. for now manually works.
if you are using yarn than you can
or npm