인프런 커뮤니티 질문&답변
Encountered two children with the same key 에러
작성
·
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={index} post={post} />
))}
</AppLayout>




