gpt4 book ai didi

html - react : Action on variable change

转载 作者:太空宇宙 更新时间:2023-11-04 15:50:37 25 4
gpt4 key购买 nike

有没有办法调用变量变化(状态)的方法。如何获取更改了哪些组件的列表?

 componentDidUpdate(prevProps, prevState) {

const {ID} = this.state
if (this.ID !== this.previousID || this.cmbID !== this.previoudcmbID) {
if(this.ID !== undefined && this.cmbID !== undefined)
{
this.reload3();

// console.log(this.prevProps)
console.log(this.state.settings[0])
console.log(this.prevState.settings[0])

}



}
this.prevState = this.state;
}

最佳答案

终于解决了

componentDidUpdate(PrevProps, prevState){
if(this.state.cmbID !== prevState.cmbID){

this.reload2()
}
if(this.state.ID !== prevState.ID){

this.reload3()
}
}

关于html - react : Action on variable change,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50696093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com