inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Tạo NodeBird SNS bằng React

6-5. Cách sử dụng nâng cao của thành phần liên kết

콘솔에러가 나요ㅠㅠ

348

epsozk22765

9 câu hỏi đã được viết

0

Warning: Encountered two children with the same key, `[object Object]`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.

이렇게 오류가 납니다. 다른분 질문을 보니 key에서 createdAt이 문제인 것 같은데 어떻게 수정을 해야할 지 모르겟습니다ㅠ

return (
<div>
<Card
key={+post.createdAt}
cover={post.img && <img alt="example" src={post.img} />}
actions={[
<Icon type="retweet" key="retweet" />,
//////////////////////////
PostCard.propTypes = {
post: PropTypes.shape({
User: PropTypes.object,
content: PropTypes.string,
img: PropTypes.string,
createdAt: PropTypes.object,
}),
};

react javascript

Câu trả lời 5

0

zerocho

 지금 Card쪽을 보고계신데 Card가 아니라 PostCard를 보셔야 합니다. PostCard가 쓰이는 곳이요.

0

epsozk22765

맞는 것 같아요...

---> index.js:1 Warning: Failed prop type: Invalid prop `post.createdAt` of type `string` supplied to `PostCard`, expected `object`.

    in PostCard (at pages/index.js:23)

---> index.js:1 Warning: Encountered two children with the same key, `[object Object]`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.


PostCard.propTypes = {
post: PropTypes.shape({
User: PropTypes.object,
content: PropTypes.string,
img: PropTypes.string,
createdAt: PropTypes.object,
}),
};

0

zerocho

에러메시지의 위치가 Card가 맞나요??

0

epsozk22765

createdAt 2020-04-12T08:32:59.000Z

PostCard.js:39 createdAt 2020-04-12T08:32:01.000Z

PostCard.js:39 createdAt 2020-04-10T07:20:10.000Z

PostCard.js:39 createdAt 2020-04-10T07:20:00.000Z

PostCard.js:39 createdAt 2020-04-10T07:04:42.000Z

전부 다른 값이 나옵니다.

그리고  post.id로 했는데도 같은 에러가 나요ㅠㅠ

Warning: Encountered two children with the same key, `[object Object]`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.

<Card
key={+post.id}
cover={post.img && <img alt="example" src={post.img} />}
actions={[

0

zerocho

위에서 console.log('createdAt', post.createdAt)을 먼저 해서 값을 확인해보세요. 고유하기만 하면 되므로 post.id 이런 고유값이 더 낫습니다.

next 10 이상에서는 redux dev tool 구동이 안되나요?

0

275

1

세션 갱신 문의 건

0

492

7

배포 진행 후 Highlight updates components render 표시

0

450

1

똑같은 기능을 하는 테이블

0

455

4

관계형

0

314

2

프론트 서버를 이용하지 않는경우

1

302

3

인피니트 스크롤링 사용시 오류

0

280

0

계속 이런에러가 떠서 해결하기는 했는데 어떤 의미인지 모르겠습니다.

0

436

2

req.user가 언제 생성되나요??

0

332

2

Cannot read property 'id' of null 에러

0

336

1

리트윗한 게시글 불러오는 sequelize

0

255

1

result.data에서 images인 이유

0

283

2

takeLatest에 대한 질문입니다.

1

344

2

프론트에서 express를 사용하지 않을때 동적라우팅

0

504

6

getInitialProps가 클라이언트에서 수행되는 이유?

0

261

1

리로드하면 팔로우 언팔로우 값이 초기화 되는 문제입니다.

0

448

2

스타일드 컴포넌트와 className을 통한 스타일 적용의 차이에 대해 궁금합니다

0

587

2

할인 쿠폰 사용이 안되는되요 (848-f9af83f183e3)

0

368

1

nodejs mvc 패턴

0

981

4

사용하고 보니, 람다 구성이 궁금합니다!

0

269

1

제로초님

0

448

1

새로고침 로그인 풀림 문제.

0

249

1

안녕하세요. 강의 너무 감사합니다

0

159

1

제로초님

0

174

1