[英]Uncaught error: Objects are not valid as a React child
I'm really new to react, im trying to build an app in that library, however i keep running into this error and i don't know what it does nor how to resolve it.我真的很陌生,我试图在那个库中构建一个应用程序,但是我一直遇到这个错误,我不知道它做了什么,也不知道如何解决它。 I'm just trying to pass data from a parent component to a child component, previously i was trying to do that from a fetch and from an array but now it's just basic props and still i get this error.我只是想将数据从父组件传递到子组件,以前我试图通过获取和数组来做到这一点,但现在它只是基本道具,但我仍然收到此错误。
the parent component父组件
import axios, * as others from 'axios';
import Row from 'react-bootstrap/Row';
import Cerd from "./Cerd";
import movieArray from "./MovieArray";
export function UseFetch(message){
let number = movieArray.length;
console.log(number);
let image = movieArray[0].image;
let text = movieArray[0].title;
let actors = movieArray[0].actors;
const toStringer = text.toString();
console.log(toStringer);
return(
<div className="row-wrapper">
<Row>
<Cerd title="ciao"/>
</Row>
</div>
)
}
the child component:子组件:
mport Card from 'react-bootstrap/card';
export default function Cerd(title){
console.log(title);
return(
<div>{title}</div>
)
}
Here's the error:这是错误:
I already tried to change computer and search for solutions online but nothing changes, I0m not passing an array or an object in the props as it is just a simple string.我已经尝试更换计算机并在线搜索解决方案但没有任何变化,我没有在道具中传递数组或对象,因为它只是一个简单的字符串。 This is a killer error because it's not the first time that happens to me and i still haven't found what to do when it happens... can somebody help?这是一个致命的错误,因为这不是第一次发生在我身上,而且我仍然没有找到发生时该怎么做......有人可以帮忙吗?
In react component props passing, you cannot take it like taking from function.在 React 组件 props 传递中,你不能像从函数中获取一样。 You defined "title" in props of component, but you cannot take it as a variable.您在组件的道具中定义了“标题”,但不能将其作为变量。 You have to take it as shorthand.你必须把它当作速记。
// your code;
export default function Cerd(title){
// must be;
\/
export default function Cerd({title}){
Try ({title}) instead of (title).尝试 ({title}) 而不是 (title})。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.