inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

React로 NodeBird SNS 만들기

6-5. Link 컴포넌트 고급 사용법

콘솔에러가 나요ㅠㅠ

347

생글탱글

작성한 질문수 9

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

답변 5

0

제로초(조현영)

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

0

생글탱글

맞는 것 같아요...

---> 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

제로초(조현영)

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

0

생글탱글

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

제로초(조현영)

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

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

0

272

1

세션 갱신 문의 건

0

482

7

배포 진행 후 Highlight updates components render 표시

0

445

1

똑같은 기능을 하는 테이블

0

447

4

관계형

0

312

2

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

1

299

3

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

0

278

0

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

0

433

2

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

0

330

2

Cannot read property 'id' of null 에러

0

333

1

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

0

252

1

result.data에서 images인 이유

0

281

2

takeLatest에 대한 질문입니다.

1

342

2

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

0

501

6

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

0

258

1

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

0

445

2

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

0

585

2

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

0

365

1

nodejs mvc 패턴

0

975

4

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

0

266

1

제로초님

0

445

1

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

0

247

1

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

0

157

1

제로초님

0

170

1