강의

멘토링

커뮤니티

Inflearn Community Q&A

shimyuseob4173's profile image
shimyuseob4173

asked

[Renewal] Creating NodeBird SNS with React

Query string and lastId method

Encountered two children with the same key 에러

Written on

·

8.1K

0

pages > index.js 에서 PostCard key값을 post.id로 주고 회원가입 창으로 이동하면 Encountered two children with the same key 에러가 발생합니다. 그런데 index로 값을 주면 또 에러가 안나네요...?ㅜㅜㅜㅜ

index는 사용하면 안되는걸로 알고 있어서 key값을 post.id + post.content로 줬는데도 에러가 발생합니다.

index값으로 키값을 줘도 괜찮나요?

    <AppLayout>
      {me && <PostForm />}
      {mainPosts.map((post, index) => (
        <PostCard key={indexpost={post/>
      ))}
    </AppLayout>
reduxreactnodejsexpressNext.js

Answer 2

0

SEOVI님의 프로필 이미지
SEOVI
Questioner

답변 감사드립니다.

0

zerocho님의 프로필 이미지
zerocho
Instructor

mainPosts를 console.log찍어보세요. 그리고 중복된 데이터가 두 개 이상 들어있는지 확인하시고, 들어있다면 왜 중복된 데이터가 들어갔는지 확인해보시면 됩니다. redux-devtools로 mainPosts의 변화를 추적해보세요.

shimyuseob4173's profile image
shimyuseob4173

asked

Ask a question