diff --git a/frontend/src/components/Pagination.jsx b/frontend/src/components/Pagination.jsx index c5c138f..e45e1d6 100644 --- a/frontend/src/components/Pagination.jsx +++ b/frontend/src/components/Pagination.jsx @@ -7,10 +7,10 @@ import { IconChevronLeft, IconChevronRight, IconChevronsLeft, IconChevronsRight */ function Pagination({ currentPage, totalPages, totalItems, pageSize, onPageChange }) { const [jumpToPage, setJumpToPage] = useState(''); - - if (totalPages <= 1) return null; + // Хуки должны вызываться безусловно (до любого return) const pages = useMemo(() => { + if (totalPages <= 1) return []; const result = []; let start = Math.max(1, currentPage - 2); let end = Math.min(totalPages, currentPage + 2); @@ -31,6 +31,9 @@ function Pagination({ currentPage, totalPages, totalItems, pageSize, onPageChang return result; }, [currentPage, totalPages]); + // Ранний return после всех хуков + if (totalPages <= 1) return null; + const startItem = (currentPage - 1) * pageSize + 1; const endItem = Math.min(currentPage * pageSize, totalItems);