[英]VS Code Doesn't Understand Shorthand React.Fragment Tags In Tsx
I've setup a create-react-app with TypeScript:我已经使用 TypeScript 设置了一个 create-react-app:
npx create-react-app my-app --template typescript
However, whenever I try to use a shorthand <React.Fragment> tag, like:但是,每当我尝试使用简写 <React.Fragment> 标记时,例如:
function App() {
return (<>
<header>Hello World</header>
</>);
}
VS Code complains that it's an error: VS Code 抱怨这是一个错误:
Type expected. (6:13)
4 |
5 | function App() {
> 6 | return <><header>Hello World</header></>;
| ^
7 | }
8 |
9 | export default App;
It is of course understood & rendered just fine by React itself. React 本身当然可以很好地理解和渲染它。 Why is VS Code indicating this as an error, & how might I be able to fix it?
为什么 VS Code 将此指示为错误,我该如何解决?
This is not default behavior of VS Code.这不是 VS Code 的默认行为。 It is likely caused by an extension.
这很可能是由扩展引起的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.