繁体   English   中英

错误:使用 JSX 时,“React”必须在 scope 中

[英]Error: 'React' must be in scope when using JSX

在 debian 10 上用 React 做一个测试项目,在 Windows 上用 VScode 8.1,当在项目文件夹中使用命令yarn start时,出现错误:

./src/App.js
  Line 6:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 7:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 8:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 9:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 10:  'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 12:   'React' must be in scope when using JSX  react/react-in-jsx-scope

import React from 'react'; "react/react-in-jsx-scope": "off" 还有什么问题?

  1. 在 js 文件的开头部分添加。

从“反应”导入反应

这将解决问题

我遇到了同样的问题,通过运行 npm audit fix --force 解决了。 我会尝试重新安装软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM