부모 구성 요소가 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>
);
}
});
을 시도 위에 루프를 필요로하고 각 역할
에 대한 요소를 렌더링합니다. 루핑을 통해 변수에 저장해야하며 그 변수를 인쇄 할 수있는 것보다 필요합니다. – SPViradiya