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);
});
添加回答
舉報