我有这个.tsx文件
我有这个.tsx文件
import React, { Component } from 'react';
export class SidebarItem extends Component {
constructor (props) {
super(props);
}
render () {
return (<li>{this.props.children}</li>);
}
}
但是,TypeScript会抛出此错误:
错误TS2339:类型’SidebarItem’上不存在属性’props’.
解决方案是安装React Types定义
yarn add -DE @types/react
但是,TypeScript会抛出此错误:
错误TS2339:类型’SidebarItem’上不存在属性’props’.
解决方案是安装React Types定义
yarn add -DE @types/react