If you meant to render a collection of children, use an array instead.

Hyunwoo Seo·2022년 7월 10일
0

ErrorCode

목록 보기
6/16
post-thumbnail

If you meant to render a collection of children, use an array instead.

데이터타입이 array인데, 각 요소(여기서는 item, 데이터 타입은 Object)객체를 그대로 렌더링 하려고 했기 때문에 에러가 발생하였다.
즉, Object데이터를 그대로 렌더링 하려고 했기 때문에 에러가 발생한 것이다.

      <List
        dataSource={me.Followings}
        renderItem={item => {
          return (
            <List.Item>
              <Card actions={[<StopOutlined key='stop' />]}>
                <Card.Meta description={item} /> // <= 에러의 원인
              </Card>
            </List.Item>
          );
        }}
      />

array의 각 요소의 특정 attribute(여기서는 item.id, 데이터 타입은 Number)를 가져오는 것으로 수정하여 에러를 해결하였다

      <List
        dataSource={me.Followings}
        renderItem={item => {
          return (
            <List.Item>
              <Card actions={[<StopOutlined key='stop' />]}>
                <Card.Meta description={item.id} /> // <= id 값을 가져오는 것으로 해결
              </Card>
            </List.Item>
          );
        }}
      />

출처 : https://velog.io/@bigbrothershin/React-Objects-are-not-valid-as-a-React-child-%EC%97%90%EB%9F%AC-%EC%B2%98%EB%A6%AC

0개의 댓글