问题描述
在反应17中不一定使用
import React from 'react';
但是如果我没有它,那么埃斯林特给了我错误
'React' must be in scope when using JSX react/react-in-jsx-scope
module.exports = {
parser: "babel-eslint",env: {
browser: true,node: true,es6: true,jest: true,},extends: [
"eslint:recommended","plugin:react/recommended","plugin:jsx-a11y/recommended"
],plugins: [
"react","react-hooks","jsx-a11y",],rules: {
strict: 0,"react-hooks/rules-of-hooks": "error","react-hooks/exhaustive-deps": "warn"
},settings: {
react: {
version: "detect"
}
}
}
反应17?
非常感谢
解决方法
您可以在React docs中了解它。
如果您使用的是
eslint-plugin-react
,则不再需要react/jsx-uses-react
和react/react-in-jsx-scope
规则,可以将其关闭或删除。
{
// ...
"rules": {
// ...
"react/jsx-uses-react": "off","react/react-in-jsx-scope": "off"
}
}