我有一个返回此的箭头函数:
return (
<div className="posts">
<Post />
{dataApi.map((post) => {
return <Post post={post} key={uuidv4()} />;
})}
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
在我的 Post 组件中,我尝试导入作者、日期和 props 中传递的文本,但它告诉我该数据未定义。但是,当我 console.log (发布)时,我的数据出现......这是代码:
const Post = ({post}) => {
//const {author, date_creation, message} = post
return (
<div className="post">
<div className="post__author_group">
<Avatar className={"post__avatar"} />
<div className="post__author_and_date">
<Author className="post__author" author={'author'} />
<Date className="post__date" date={'date_creation'} />
</div>
</div>
<Text message={'message'} />
{/* <Media /> */}
<Interactions />
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
如果我console.log(post),我可以看到我的5个对象,但是如果我取消注释“//const {author, date_creation, message} = post”并将author = {'author "}替换为author …