简体   繁体   English

对象作为 React 子级无效如果您要渲染子级集合,请改用数组

[英]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.

相关问题 对象作为 React 子级无效(找到:object 和键 {children})。 如果您打算渲染一组孩子,请改用数组 - 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 React错误:对象作为React子对象无效,如果要渲染子代集合,请改用数组 - React Error: Objects are not valid as a React child,If you meant to render a collection of children, use an array instead react matrerial ui Error: Objects are not valid as a React child 如果您打算渲染一组子项,请改用数组 - react matrerial ui Error: Objects are not valid as a React child If you meant to render a collection of children, use an array instead 对象作为 React 子级无效。 如果您打算渲染一组子项,请改用数组 - 错误 Solidity - React - Objects are not valid as a React child. If you meant to render a collection of children, use an array instead - Error Solidity - React “对象作为 React 子对象是无效的。 如果您打算渲染一组子项,请改用数组。” 错误 - “Objects are not valid as a React child. If you meant to render a collection of children, use an array instead.” error 如何修复错误:对象作为 React 子对象无效。 如果您打算渲染一组孩子,请改用数组 - How to fix error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead 对象作为 React 子级无效(找到:object 和键 {value})。 如果您打算渲染一组孩子,请改用数组 - Objects are not valid as a React child (found: object with keys {value}). If you meant to render a collection of children, use an array instead 对象作为 React 子级无效(找到:object 和键 {weight})。 如果您打算渲染一组孩子,请改用数组 - Objects are not valid as a React child (found: object with keys {weight}). If you meant to render a collection of children, use an array instead 我不断收到此错误 Objects are not valid as a React child {} 如果您要呈现子集合,请改用数组 - I keep getting this error Objects are not valid as a React child {} If you meant to render a collection of children, use an array instead 对象作为 React 子级无效(找到:object 和键 {_delegate})。 如果您打算渲染一组孩子,请改用数组 - Objects are not valid as a React child (found: object with keys {_delegate}). If you meant to render a collection of children, use an array instead
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM