From cf563314934f788c5ed13562fe4626f45e4ea84e Mon Sep 17 00:00:00 2001 From: Iryna Date: Wed, 28 Jan 2026 17:11:50 +0200 Subject: [PATCH 1/4] Solution --- src/App.tsx | 104 +++++++---------------- src/components/Pagination/Pagination.tsx | 79 ++++++++++++++++- 2 files changed, 107 insertions(+), 76 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 189a990c8..382dcaa40 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,25 @@ -import React from 'react'; +import React, { useState } from 'react'; import './App.css'; import { getNumbers } from './utils'; +import { Pagination } from './components/Pagination'; // eslint-disable-next-line @typescript-eslint/no-unused-vars const items = getNumbers(1, 42).map(n => `Item ${n}`); export const App: React.FC = () => { + const [currentPage, setCurrentPage] = useState(1); + const [perPage, setPerPage] = useState(5); + const startIndex = (currentPage - 1) * perPage; + const endIndex = Math.min(startIndex + perPage, items.length); + const visibleItems = items.slice(startIndex, startIndex + perPage); + return (

Items with Pagination

- Page 1 (items 1 - 5 of 42) + Page {currentPage} (items {startIndex + 1} - {endIndex} of{' '} + {items.length})

@@ -19,7 +27,14 @@ export const App: React.FC = () => {