![](/img/trans.png)
[英]Objects are not valid as a React child (found: object with keys {children}). If you meant to render a collection of children, use an array instead
[英]Objects are not valid as a React child If you meant to render a collection of children, use an array instead
當我將詳細數據傳遞給模態顯示時出現此錯誤。 實際上 function 是當用戶單擊帖子時,會出現一個模態以顯示顯示詳細信息的模態。 我正在使用 redux 進行 state 管理。 這是我的代碼
錯誤對象作為 React 子對象無效(發現:object 鍵為 {nid、title、content、noticeType、creationDate、updatedDate})。 如果您打算渲染一組子項,請改用數組。
noticeModal.jsx
const ModalDialog = ({open ,onClose, data}) => {
return (
<Dialog style={{width: '100%'}} maxWidth={"sm"} onClose={() => onClose()} aria-labelledby="customized-dialog-title" open={open}>
<DialogContent dividers>
<table style={{width: '100%'}}>
<tr>
<TableRow title>No</TableRow>
<TableRow
>
{data.nid}</TableRow>
</tr>
<tr>
<TableRow title>Type</TableRow>
<TableRow>{data.noticeType}</TableRow>
</tr>
<tr>
<TableRow title>Title</TableRow>
<TableRow>{data.title}</TableRow>
</tr>
</table>
<br/>
通知.jsx
<ModalDialog
open={this.state.openDetailModal}
onClose={this.closeDetailModal}
data = {this.props.noticeDetail}
/>
錯誤對象作為 React 子對象無效(發現:object 鍵為 {nid、title、content、noticeType、creationDate、updatedDate})。 如果您打算渲染一組子項,請改用數組。
這通常是由渲染 object 或數組引起的。
它可以很容易地復制。
<Component>{data}</Component>
但是,我在您的組件中沒有看到任何此類事件。 您確定您正在檢查正確的組件嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.