Skip to content
This repository was archived by the owner on Dec 10, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@commitlint/config-conventional": "17.0.3",
"@commitlint/config-nx-scopes": "17.0.0",
"@commitlint/cz-commitlint": "17.0.3",
"@commitlint/prompt-cli": "^17.6.1",
"@commitlint/types": "17.0.0",
"@jscutlery/semver": "2.25.2",
"@nrwl/cli": "14.5.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/remix-pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"sideEffects": false,
"dependencies": {
"clsx": "~1.0.0",
"react-icons": "~4.0.0",
"ufo": "~0.8.0"
"react-icons": "~4.0.0"
},
"peerDependencies": {
"@remix-run/react": "^1.8.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/remix-pagination/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"react",
"react-dom",
"react-icons",
"regenerator-runtime",
"ufo"
"regenerator-runtime"
],
"development": [
"@nrwl/eslint-plugin-nx",
Expand Down
12 changes: 7 additions & 5 deletions packages/remix-pagination/src/lib/remix-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
BsChevronLeft as PreviousIcon,
BsChevronRight as NextIcon,
} from 'react-icons/bs';
import { withQuery } from 'ufo';

import { Item as ItemComponent } from './components/Item';
import { Link as LinkComponent } from './components/Link';
Expand Down Expand Up @@ -59,9 +58,8 @@ export const RemixPagination: FC<RemixPaginationProps> = ({
}) => {
const [params] = useSearchParams();

const query = Object.fromEntries(params.entries());

const currentPage = Number(query[pageQuery] || 1);
const currentPage = Number(params.has(pageQuery) ? params.get(pageQuery) : 1);

const isLastPage = currentPage * size >= total;
const pageNumbers = getPageNumbers({
Expand All @@ -71,8 +69,12 @@ export const RemixPagination: FC<RemixPaginationProps> = ({
ellipsesText,
});

const url = (page: string | number) =>
withQuery('', { ...query, [pageQuery]: page.toString() });

const url = (page: string | number) => {
const pageParams = new URLSearchParams(params)
pageParams.set(pageQuery,page.toString())
return '?'+pageParams.toString()
};

if (pageNumbers.length === 0) return null;

Expand Down