Warning: Each child in a list should have a unique “key” prop

前端 未结 1 1751
小鲜肉
小鲜肉 2020-12-05 07:55

I\'m building an app using the google books API and I appear to be passing a unique key to each child in the list, but the error won\'t go away. I must be doing something wr

相关标签:
1条回答
  • 2020-12-05 08:26

    The key needs to go on the outermost returned element. In your specific case, that means changing this:

                <div className="col col-lg-4 grid-wrapper">
                    <BookCard 
                        key={book.id}
    

    to this:

                <div className="col col-lg-4 grid-wrapper" key={book.id}>
                    <BookCard 
    
    0 讨论(0)
提交回复
热议问题