Skip to content

Commit

Permalink
refactor: remove qs-stringify dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign committed Oct 8, 2024
1 parent 638d03c commit e6df11f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 43 deletions.
45 changes: 11 additions & 34 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 @@ -44,9 +44,6 @@
},
"author": "Andrea Carraro <me@andreacarraro.it>",
"license": "ISC",
"dependencies": {
"qs-stringify": "^1.2.1"
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
"@testing-library/react": "^16.0.0",
Expand All @@ -58,6 +55,7 @@
"next": "^14.2.4",
"next-13": "npm:next@^13.5.6",
"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 e6df11f

Please sign in to comment.