Skip to content

Commit

Permalink
refactor: remove qs-stringify dependency (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign authored Oct 26, 2024
1 parent d906493 commit 232c3b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-seahorses-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'next-use-contextual-routing': minor
---

refactor: remove qs-stringify dependency in favour of native URLSearchParams
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
},
"author": "Andrea Carraro <[email protected]>",
"license": "ISC",
"dependencies": {
"qs-stringify": "^1.2.1"
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
"@testing-library/react": "^16.0.0",
Expand All @@ -55,6 +52,7 @@
"jest-environment-jsdom": "^29.3.1",
"next": "^15.0.0",
"prettier": "^3.3.2",
"qs-stringify": "^1.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "^3.16.1",
Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback } from 'react';
import { useRouter } from 'next/router.js';
import stringify from 'qs-stringify';
export const RETURN_HREF_QUERY_PARAM = '_UCR_return_href';

/**
Expand Down Expand Up @@ -36,11 +35,11 @@ export function useContextualRouting(): {
(extraParams?: Record<string, string | number>) =>
router.pathname +
'?' +
stringify(
Object.assign({}, router.query, extraParams, {
[RETURN_HREF_QUERY_PARAM]: returnHref,
})
),
new URLSearchParams({
...router.query,
...extraParams,
[RETURN_HREF_QUERY_PARAM]: returnHref,
}).toString(),
[queryHash, returnHref]
);

Expand Down

0 comments on commit 232c3b3

Please sign in to comment.