Open myakkk1 opened 1 month ago
import React, { useState } from 'react';
const booksData = [ { id: 1, title: '1984', author: 'George Orwell', available: true }, { id: 2, title: 'To Kill a Mockingbird', author: 'Harper Lee', available: true }, { id: 3, title: 'The Great Gatsby', author: 'F. Scott Fitzgerald', available: true }, ];
const App = () => { const [books, setBooks] = useState(booksData);
const handleCheckout = (id) => { setBooks(books.map(book => book.id === id ? { ...book, available: false } : book )); };
const handleReturn = (id) => { setBooks(books.map(book => book.id === id ? { ...book, available: true } : book )); };
return (
Автор: {book.author}
Статус: {book.available ? 'Доступна' : 'На руках'}
); };
export default App;
import React, { useState } from 'react';
const booksData = [ { id: 1, title: '1984', author: 'George Orwell', available: true }, { id: 2, title: 'To Kill a Mockingbird', author: 'Harper Lee', available: true }, { id: 3, title: 'The Great Gatsby', author: 'F. Scott Fitzgerald', available: true }, ];
const App = () => { const [books, setBooks] = useState(booksData);
const handleCheckout = (id) => { setBooks(books.map(book => book.id === id ? { ...book, available: false } : book )); };
const handleReturn = (id) => { setBooks(books.map(book => book.id === id ? { ...book, available: true } : book )); };
return (
Библиотека
Доступные книги:
{books.map(book => (-
))}
{book.title}
Автор: {book.author}
Статус: {book.available ? 'Доступна' : 'На руках'}
{book.available ? ( ) : ( )}); };
export default App;