Skip to content

Commit

Permalink
PaginatedList: fix offset not included in qParams
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Oct 18, 2023
1 parent 9b362c1 commit 330c7d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ export default function PaginatedList<TItem extends object>({
perPage = DEFAULT_PER_PAGE_LIMIT,
...queryOptions
}: Props<TItem>) {
const [currentPage, setPage] = useState(1);
const query = useQuery(route, {
...queryOptions,
query: { ...queryOptions.query, limit: perPage },
query: {
...queryOptions.query,
limit: perPage,
offset: (currentPage - 1) * perPage,
},
});
const [currentPage, setPage] = useState(1);

const items = query.data?.results ?? [];

Expand Down

0 comments on commit 330c7d9

Please sign in to comment.