‘Eslint’在使用JSX时必须在范围内,react/react-in-jsx-scope。

huangapple go评论76阅读模式
英文:

Eslint 'React' must be in scope when using JSX react/react-in-jsx-scope

问题

When I run yarn eslint . I got this result:

 5:10 error  'React' must be in scope when using JSX  react/react-in-jsx-scope

✖ 1 problem (1 error, 0 warnings) 

‘Eslint’在使用JSX时必须在范围内,react/react-in-jsx-scope。

The problem is that in this file, I don't need to import React because the IDE is showing:

 'React' is declared but its value is never read.ts(6133) 

‘Eslint’在使用JSX时必须在范围内,react/react-in-jsx-scope。

So what do I do to resolve this situation?

英文:

When I run yarn eslint . I got this result:

  5:10  error  'React' must be in scope when using JSX  react/react-in-jsx-scope

✖ 1 problem (1 error, 0 warnings)

‘Eslint’在使用JSX时必须在范围内,react/react-in-jsx-scope。

The problem is that in this file, I dont need to import React, because the IDE showing:

'React' is declared but its value is never read.ts(6133)

‘Eslint’在使用JSX时必须在范围内,react/react-in-jsx-scope。

So what do I do to resolve this situation?

答案1

得分: 2

React的新版本在编写JSX时不需要导入React,并且为了修复eslint,这是答案:https://stackoverflow.com/a/64646593/11410031

英文:

React in new version doesn't need to import React when writing JSX, and to fix eslint, this is the answer: https://stackoverflow.com/a/64646593/11410031

huangapple
  • 本文由 发表于 2023年4月20日 01:09:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76057156.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定