【发布时间】:2021-04-15 10:46:09
【问题描述】:
我相信我已经用正确的方式声明了interface 并用类实现了。但仍然出现错误:
Property 'show' does not exist on type 'Readonly<{}>'.ts(2339)
任何人帮助我进一步了解这里?
这是我的代码:
interface GlobalForm {
show:boolean
}
export class Footer extends React.Component<GlobalForm> {
constructor(props:GlobalForm){
super(props);
this.state = {
show:false
}
}
globalForm = (event:React.MouseEvent):void => {
event.preventDefault();
this.setState(() => ({show:!this.state.show}))
}
错误:
【问题讨论】:
标签: reactjs typescript-typings tsx