reactjs - 在组件上使用 .map 会导致组件返回“渲染中没有返回任何内容......”错误
问题描述
我Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null
从我的反应组件中得到。它工作正常,然后我添加了一个.map
复制组件并开始收到错误。我看过这个答案,这个答案,这个答案和这个答案,但没有找到我的答案
const AdvisorData = ({weekListForAllAdvisorsOfState}) => {
const data = usePreloadedQuery(query, queryReference);
let {forecast} = data
forecast.map((ind, index) => {
return (
<TableRow key={ind.referralCode}>
<AdvisorTableCell>
<pw-subtitle size="small" color="black">{ind.referralCode}</pw-subtitle>
<div style={{ flexBasis: "100%" }} />
<pw-subtitle size="small" color="grey">{ind.postalCode}</pw-subtitle>
</AdvisorTableCell>
</TableRow>
)
})
}
解决方案
你试过这种方式吗?
const AdvisorData = ({weekListForAllAdvisorsOfState}) => {
const data = usePreloadedQuery(query, queryReference);
let {forecast} = data
return (
forecast.map((ind, index) => {
<TableRow key={ind.referralCode}>
<AdvisorTableCell>
<pw-subtitle size="small" color="black">{ind.referralCode}</pw-subtitle>
<div style={{ flexBasis: "100%" }} />
<pw-subtitle size="small" color="grey">{ind.postalCode}</pw-subtitle>
</AdvisorTableCell>
{weekListForAllAdvisorsOfState}
</TableRow>
)
}})
推荐阅读
- string - 在VBScript中连接字符串的快速方法是什么
- java - 如何在 JNI 中调用 Android ByteBuffer.putFloat()
- ios - Xcode 11.4 循环引用错误
- python - Beautifulsoup 干净的打印和换行符
- javascript - Google Analytics 事件未触发包含匹配类型
- sql - 是否可以简化此 SQL?
- android - 使用 xamarin Implimentation 在同一平台中的应用程序之间切换
- api - 关于来自 Google Places API 的附近搜索请求的问题
- javascript - 如何选择特定的 JSON 对象?
- unity3d - Unity 像素艺术中的故障