子コンポーネントにpropsを渡そうとしています。私が得ている問題は、渡すべきプロパティの1つが配列であるということです。私は次のエラーを取得以下のように登録した小道具を渡すしようとした場合オブジェクトを反応のマップ関数でオブジェクトとして渡す方法
{
name: "Rowan Powell",
_id: "58658484d139c337601cfb6d",
updatedOn: "2016-12-29T21:47:48.185Z",
createdOn: "2016-12-29T21:47:48.185Z"
},
{
name: "Savannah Powell",
_id: "58658488d139c337601cfb6e",
updatedOn: "2016-12-29T21:47:52.145Z",
createdOn: "2016-12-29T21:47:52.145Z"
}
:配列は次のようになり登録もう少しコンポーネント整理であるために
Uncaught (in promise) Error: Objects are not valid as a React child (found: object with keys {name, _id, updatedOn, createdOn}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons.
return (
<div>
{this.state.events.map((event, key) => {
return (
<div key={key}>
<Event
title={event.title}
date={event.date}
time={event.time}
description={event.description}
presentor={event.presentor}
location={event.location}
registered={event.registrants}
max_reg={event.max_reg}
id={event._id} />
</div>
)
})}
</div>
)
はそうしてみます。コードを表示できますか? –
パーフェクトは実際に助けた。子コンポーネントにエラーが見つかりました。ありがとうございました! – jpdesigning
this.state.eventsは配列でなければなりません。配列には任意のオブジェクトを含めることができます。あなたはそれにマップを使用することができます。 –