2 回答
TA贡献1951条经验 获得超3个赞
你没有从你的 if 子句中返回任何东西,因此 React 不会开始渲染这些卡片。
const createCards = runTriggered => {
let newCards, view = null;
/**
* @param {*} deviceId
* get the compliance details
*/
let agag = getComplianceDetails(this.props.deviceId).then(data => {
if (data) {
return data;
}
// .then afterwards will fail if no data is present
});
if (runTriggered) {
// No return here, assuming createCards is treated as a promise you can try:
// return agag.then(...
agag.then(data => {
newCards = data;
view = (...);
return view;
});
} else {
view = (...);
return view;
}
};
```
TA贡献1853条经验 获得超18个赞
let agag = getComplianceDetails(this.props.deviceId)
.then(data => data.json())
.then(parsedData =>{
if (parsedData) {
return parsedData;
}
else{
console.log ("This function is not returning anything. Let's check why!")
}
})
.catch((error)=>{
console.log ("Let's see what's going on here -> ", error);
});
添加回答
举报