这里需要引入 React 不然ts会报错
来源:7-7 【路由拓展】如何支持类组件

Darkholme
2022-06-14
老师这里不引入 React 了话会报’React’ refers to a UMD global, but the current file is a module. Consider adding an import instead. 为啥呢?
写回答
1回答
-
阿莱克斯刘
2022-06-29
如果不想引用react,那么你得先确保
typescript
至少是 version 4.1react
andreact-dom
至少是 version 17tsconfig.json
的jsx
compilerOption 需要改为react-jsx
orreact-jsxdev
参考:
https://stackoverflow.com/questions/64656055/react-refers-to-a-umd-global-but-the-current-file-is-a-module
00
相似问题