私はUsersTable
という親コンポーネントを持っています(それは他のコンポーネントのチレールで、その小道具としてusers
とroles
です)。 getRoles()
関数は、ajaxリクエストを使用してユーザーのすべての役割を取得しています。結果はrender()
に戻り、変数allroles
に格納されます。 allroles
は、オブジェクトの配列([Object, Object, Object]
)で、その子コンポーネントとして子コンポーネントUserRow
に送信されます。しかし、私はこのエラーが発生しています:オブジェクトの配列をReactコンポーネントの小道具として持っている
invariant.js:44 Uncaught Error: Objects are not valid as a React child
(found: object with keys {description, id, links, name}). 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. Check the render method of
`UserRow`.
誰かが私を修正する手助けをしてもらえますか?あなたがuserRolesをレンダリングする際に問題があるように見えます
export const UserRow = React.createClass({
render(){
return (
<tr>
<td>{this.props.userEmail}</td>
<td>{this.props.userRoles}</td>
</tr>
);
}
});
を試してみてください