更漂亮 / ESLint / 反应

Prettier / ESLint / React

从菜鸟导入 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'));
import React from 'react';

export interface IProps {
    greeting: string;
}

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

export default Hello;

/Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx TypeScript error in /Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx(undefined,undefined):
'React' is declared but its value is never read. TS6133

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

src/components/Hello.tsx
Line 6:12: 'React' must be in scope when using JSX react/react-in-jsx-scope

Search for the keywords to learn more about each error.

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