Warning: Each child in a list should have a unique "key" prop.
Unanswered
Ant posted this in #help-forum
AntOP
Hi all,
I'm getting this error in my console:
I double-checked my components and I have
I'm getting this error in my console:
Warning: Each child in a list should have a unique "key" prop.
Check the top-level render call using <div>. See https://reactjs.org/link/warning-keys for more information.
I double-checked my components and I have
key={post._id} in all the relevant components. The post._id are unique as they are generated by Sanity. Am I missing something?<div className="grid gap-10 md:grid-cols-2 lg:gap-10 ">
<Suspense fallback={<h2>Loading...</h2>}>
{posts.slice(0, 2).map(post => (
<PostListing
key={post._id}
post={post}
aspect="landscape"
preloadImage={true}
/>
))}
</Suspense>
</div>5 Replies
AntOP
Yeah I just checked it again, pretty sure.
@Arinji Are there any other possibilities that could've caused this error?
@Ant <@890486507872342027> Are there any other possibilities that could've caused this error?
Show me the post list component
AntOP
@Arinji sorry for the slow response!
Here it is (I don't know why I can't paste it as code and why it's attached as a .txt file)!
Here it is (I don't know why I can't paste it as code and why it's attached as a .txt file)!