更漂亮 / ESLint / React

Jer*_*emy 5 typescript reactjs eslint prettier

从菜鸟导入 TS / React 的规则冲突,但使用 Eslint / Prettier 并收到错误'React' is declared but its value is never read.,但如果我删除它,'React' must be in scope when using JSX则会弹出错误。我不明白为什么!

ReactDOM.render(<Hello greeting="Site under construction..." />, document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)
import React from 'react';

export interface IProps {
    greeting: string;
}

function Hello({ greeting }: IProps) {
    return <div>{greeting}</div>;
}

export default Hello;

Run Code Online (Sandbox Code Playgroud)

/Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx /Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx 中的 TypeScript 错误(未定义,未定义):
' React' 已声明,但其值从未被读取。TS6133

但是如果我从上面的 Hello.tsx 中删除导入

src/components/Hello.tsx
第 6:12 行:使用 JSX react/react-in-jsx-scope 时,“React”必须在范围内

搜索关键字以了解有关每个错误的更多信息。

小智 0

React 的最后一个 React 版本不需要导入。使用那个或者修复你的 eslint 这就是这里的问题