【发布时间】:2018-12-05 13:01:39
【问题描述】:
我在使用 shouldComponentUpdate 的 TypeScript 中遇到错误:
“Hello”类型中的属性“shouldComponentUpdate”不能分配给基类型
Component<IProps, any, any>中的相同属性。
在组件中:
import React, { Component } from 'react'
class Hello extends Component<IProps, any> {
shouldComponentUpdate(nextProps: IProps) { // error here
console.log(nextProps, 'nextProps')
}
....// some code
}
谁能解释一下我做错了什么?
【问题讨论】:
标签: javascript reactjs typescript