[英]Objects are not valid as a React child If you meant to render a collection of children, use an array instead
I get this error when I pass my detail data to modal to display.当我将详细数据传递给模态显示时出现此错误。 Actually the function is when user click on the post a modal appear to display Modal where detail is displayed.
实际上 function 是当用户单击帖子时,会出现一个模态以显示显示详细信息的模态。 I am using react with redux for state management.
我正在使用 redux 进行 state 管理。 This is my code
这是我的代码
Error Objects are not valid as a React child (found: object with keys {nid, title, content, noticeType, creationDate, updatedDate}).
错误对象作为 React 子对象无效(发现:object 键为 {nid、title、content、noticeType、creationDate、updatedDate})。 If you meant to render a collection of children, use an array instead.
如果您打算渲染一组子项,请改用数组。
noticeModal.jsx
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/>
Notice.jsx
通知.jsx
<ModalDialog
open={this.state.openDetailModal}
onClose={this.closeDetailModal}
data = {this.props.noticeDetail}
/>
Error Objects are not valid as a React child (found: object with keys {nid, title, content, noticeType, creationDate, updatedDate}).
错误对象作为 React 子对象无效(发现:object 键为 {nid、title、content、noticeType、creationDate、updatedDate})。 If you meant to render a collection of children, use an array instead.
如果您打算渲染一组子项,请改用数组。
This is usually caused by rendering object or array.这通常是由渲染 object 或数组引起的。
It can be easily reproduced.它可以很容易地复制。
<Component>{data}</Component>
However I don't see in your components any such occurrences.但是,我在您的组件中没有看到任何此类事件。 Are you sure you are checking the right component?
您确定您正在检查正确的组件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.