Inside the components folder, ensure you have the following files:
Book.jsx for the child component.
data.js (already provided).
Inside src folder
App.jsx for the parent component.
data.js
// data.js
/** @format */
const booksData = {
items: [
{
volume: {
title: "Effective Java",
subtitle: "Programming Language Guide",
authors: ["Joshua Bloch"],
description:
"From the source of Java's design, this guide provides the best practices and expert insights for professional Java developers. Ideal for enhancing coding efficiency and understanding Java's capabilities.",
image:
"http://books.google.com/books/content?id=ka2VUBqHiWkC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
},
},
{
volume: {
title: "Clean Code",
subtitle: "A Handbook of Agile Software Craftsmanship",
authors: ["Robert C. Martin"],
description:
"A must-read for developers striving to write clean code that enhances readability and maintainability. Includes practical advice and real-world examples from software engineering.",
image:
"http://books.google.com/books/content?id=_i6bDeoCQzsC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
},
},
{
volume: {
title: "Head First Java",
subtitle: "A Brain-Friendly Guide",
authors: ["Kathy Sierra", "Bert Bates"],
description:
"An engaging, visually-rich approach to learning Java, suitable for beginners who want a complete understanding of object-oriented programming and Java basics.",
image:
"http://books.google.com/books/content?id=lXEBwv0LYogC&printsec=frontcover&img=1&zoom=5&source=gbs_api",
},
},
{
volume: {
title: "Eloquent JavaScript, 3rd Edition",
subtitle: "A Modern Introduction to Programming",
authors: ["Marijn Haverbeke"],
description:
"Completely revised and updated, this best-selling introduction to programming in JavaScript focuses on writing real applications.",
image:
"http://books.google.com/books/content?id=FSVTDwAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
},
},
{
volume: {
title: "Professional Java for Web Applications",
subtitle: "Comprehensive Guide to Spring Framework",
authors: ["Nicholas S. Williams"],
description:
"The comprehensive Wrox guide for creating Java web applications for the enterprise This guide shows Java software developers and software engineers how to build complex web applications in an enterprise environment.",
image:
"http://books.google.com/books/content?id=cHr0AgAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
},
},
],
};
export default booksData;
2. Create the Book.jsx Child Component
In BookList.jsx, define the functional component with props and state management:
// Some code
BookList (Component)
├── div (HTML element - className="card mb-3", style={...})
│ ├── div (HTML element - className="row g-0")
│ │ ├── div (HTML element - className="col-md-4")
│ │ │ └── img (HTML element - src=image, className="img-fluid rounded-start", alt=title)
│ │ └── div (HTML element - className="col-md-8")
│ │ └── div (HTML element - className="card-body")
│ │ ├── h5 (HTML element - className="card-title", text=title)
│ │ ├── h6 (HTML element - className="card-subtitle mb-2 text-muted", text=subtitle)
│ │ ├── p (HTML element - className="card-text")
│ │ │ ├── strong (HTML element - text="Author:")
│ │ │ └── text=author
│ │ ├── p (HTML element - className="card-text", text=description)
│ │ └── button (HTML element - className=dynamic, onClick=toggleReadStatus, text=dynamic)