componentDidMount(props) {
this.interval = setInterval(() => {
if (props.count !== 0) {
this.stateHandler()
}
}, 1000)
}
我的间隔有问题,控制台给我下一个错误: 类型错误:无法读取未定义的属性“计数”。 感谢您的帮助!
答案 0 :(得分:0)
componentDidMount 在参数中不接收 props
。尝试检查道具如下:
componentDidMount() {
this.interval = setInterval(() => {
if (this.props.count !== 0) {
this.stateHandler()
}
}, 1000)
}