skip to Main Content

ReactJS each child should have unique key

I have following code where i am using book.id to as key, but for some reason it does not work. <h1>Book shop</h1> <div className="books"> {books.map(book=>( <div className="book" key={book.id}> {book.cover && <img src={book.cover} alt=""/>} <h2>{book.title}</h2> <p>{book.description}</p> <span>{book.price}</span> <button className="delete" onClick={()=>handleDelete(book.id)}>Delete</button> <button…

VIEW QUESTION

Javascript – Prop is not giving effect

This is my react component const ButtonComponent = ({ children, onClick, disabled, className = "" }) => { console.log("class name is ", className); const buttonClassName = ` bg-green-700 flex hover:bg-green-500 transition duration-300 ease-in-out text-white h-auto text-base p-2 rounded-[5px] m-2 ${…

VIEW QUESTION
Back To Top
Search