问题产生:
1.a页面 跳转 b页面 b页面赋值到 a页面里
2.场景更新某个组件的数据进行的业务处理 didupdate/deriveDataFromProps
报错: This can happen when a component repeatedly calls setData inside didUpdate. We limits the number of nested updates to prevent infinite loops.
原因:
1.组件内部调用 this.setData
会触发 didUpdate。
2.外部调用者调用 this.setData
也会触发 didUpdate。
解决:
deriveDataFromProps(nextProps) {
if (JSON.stringify(this.data.itemData) !== JSON.stringify(this.props.itemData)) {
//业务处理
}
},