I use the following methods to monitor incoming data for changes:
componentWillReceiveProps(nextProps) {
//
if (JSON.stringify(nextProps.data) !== JSON.stringify(this.props.data)) {
//
getSeriesTreeList({ brandid: nextProps.data.brandId }, (data) => {
let { carListData } = this.state;
//
getModelList({ seriesid: nextProps.data.seriesId }, (modelData) => {
//
for (let i in modelData) {
modelData[i].value = modelData[i].vmid;
modelData[i].label = modelData[i].name;
}
//
for (let i in data) {
data[i].value = data[i].SeriesID;
data[i].label = data[i].name;
data[i].isLeaf = false;
//
if (data[i].SeriesID === nextProps.data.seriesId) {
data[i].children = modelData
}
}
//
for (let i in carListData) {
if (carListData[i].value === nextProps.data.brandId) {
carListData[i].children = data;
}
}
let arr = [nextProps.data.brandId, nextProps.data.seriesId, nextProps.data.vmId];
this.setState({
carListData,
carTypeData: arr,
});
})
})
}
}
when you click to open modal, if you listen for data changes, you will call the API to query details. However, when you disable modal, no data is passed in. When you call the API, the system will report an error because there is no data to be queried. Is there any way to stop calling the interface when it is shut down?