Sobes.tech

Get data about books and their authors. Display the data in a paginated list with 10 books per page in the format: <book title> - <author> api: [link] specification: [link] if swagger does not open, in the root sber-c55-books-mock-1.0.1-oas3.1-resolved.yaml const PAGE_SIZE = 10; export default function App() { const [books, setBooks] = useState([]) const [page, setPage] = useState(1); const [loading, setLoading] = useState(false) useEffect(() => { setLoading(true); fetch('[link]') .then((res) => res.json()) .then((data) => setBooks(data)) .finally(() => setLoading(false)); }, []); const totalPage = Math.ceil(books.length / PAGE_SIZE); const start = (page - 1) * PAGE_SIZE; const currentBooks = books.slice(start, start + PAGE_SIZE); return ( <div className="App"> {loading && <p>Loading...</p>} <ul> {currentBooks.map((book) => ( <li key={book.id}>{book.title} - {book.author}</li> ))} </ul> <button onClick={() => setPage((prev) => Math.max(prev - 1, 1))} disabled={page === 1}>Previous</button> <button onClick={() => setPage((prev) => Math.min(prev + 1, totalPage))} disabled={page === totalPage}>Next</button> </div> ); } Fix errors and implement paginated list display of books with authors.

188