From 59e7b48193d30a8a0fa05f2922965a2cb0d112c9 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 12 Oct 2024 19:08:24 +0600 Subject: [PATCH] fix pagination --- src/widgets/NewsList/NewsList.tsx | 4 ++-- src/widgets/NewsList/newsStore.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/NewsList/NewsList.tsx b/src/widgets/NewsList/NewsList.tsx index a51a633..5b58d7c 100644 --- a/src/widgets/NewsList/NewsList.tsx +++ b/src/widgets/NewsList/NewsList.tsx @@ -21,7 +21,7 @@ const NewsList: React.FC = ({ useEffect(() => { getNews(activePage); - }, []); + }, [activePage]); return (
    @@ -46,7 +46,7 @@ const NewsList: React.FC = ({ next={news.next} count={news.count as number} current_count={news.results.length} - limit={20} + limit={9} />
diff --git a/src/widgets/NewsList/newsStore.ts b/src/widgets/NewsList/newsStore.ts index c39828f..628f829 100644 --- a/src/widgets/NewsList/newsStore.ts +++ b/src/widgets/NewsList/newsStore.ts @@ -22,7 +22,7 @@ export const useNewsStore = create((set) => ({ try { set({ isLoading: true }); - const res = await apiInstance.get(`/news/`); + const res = await apiInstance.get(`/news/?limit=9&offset=${(page - 1) * 9}`); set({ data: res.data }); } catch (error: unknown) {