From 9fcb7b88128d6c452f500b83ccee414e75b36f68 Mon Sep 17 00:00:00 2001 From: Siarhei Karol Date: Wed, 15 Jan 2025 14:58:29 +0300 Subject: [PATCH] minor --- src/components/Comparison/Comparison.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Comparison/Comparison.tsx b/src/components/Comparison/Comparison.tsx index 64551493..693e75a8 100644 --- a/src/components/Comparison/Comparison.tsx +++ b/src/components/Comparison/Comparison.tsx @@ -30,7 +30,11 @@ export const Comparison = () => { const handleRemoveComparisonItem = (id: string) => { if (currentPage === totalPages - 1) { - setCurrentPage(prev => (prev - 1 >= 0 ? prev - 1 : 0)); + setCurrentPage(prevValue => { + const previousPage = prevValue - 1; + + return previousPage >= 0 ? previousPage : 0; + }); } setPreviewContent(prev => prev.filter(({ id: prevId }) => prevId !== id));