报错内容如下:
在这里插入图片描述
看看是不是在componentDidUpdate钩子函数中调用了this.setState()方法,导致componentDidUpdate陷入死循环
最初的代码如下:

componentDidUpdate(preProps) {
            this.setState({
                start: this.props.start
                end:this.props.end
            })
    }

解决:在setState前判断之前的props中的value和当前props对应的value是否相等不等的话再调用setState

componentDidUpdate(preProps) {
        if (preProps.start!= this.props.start || preProps.end != this.props.end) {
            this.setState({
                start: this.props.start
                end:this.props.end
            })
        }

    }
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐