reactjs - JSX Fragment 语法生成“元素类型无效”
我尝试在 TypeScript 中使用 JSX Fragment 语法,但出现以下错误:
元素类型无效:预期为字符串(用于内置组件)或类/函数(用于复合组件),但得到的是:symbol
我正在使用:
- React 16.2.0
- React-dom 16.2.0
- Typescript 2.6.2
即使我使用 React 示例代码,它也失败了 :
public render() {
return (
<>
Some text.
<h2>A heading</h2>
More text.
<h2>Another heading</h2>
Even more text.
</>
);
}
tsconfig.json :
{
"compilerOptions": {
"baseUrl": ".",
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"experimentalDecorators": true,
"sourceMap": true,
"skipDefaultLibCheck": true,
"strict": true,
"lib": ["es6", "dom"],
"types": ["webpack-env"]
},
"exclude": [
"bin",
"node_modules",
"app/__tests__"
]
}