Skip to content

Commit

Permalink
fix: keep current nextjs query object when pushing routes by default;…
Browse files Browse the repository at this point in the history
… This fixes a problem with dynamic routes (they would loose there parameters).
  • Loading branch information
BowlingX committed Dec 21, 2022
1 parent 44f2a54 commit 0739767
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/lib/adapters/nextjs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ export const GeschichteForNextjs: FC<Props> = ({
}

if (routerPush) {
return routerPush(Router.route, { pathname, query }, routerOptions)
return routerPush(
{ pathname, query: Router.query },
{ pathname, query },
routerOptions
)
}
return Router.push(Router.route, { pathname, query }, routerOptions)
return Router.push(
{ pathname, query: Router.query },
{ pathname, query },
routerOptions
)
},
replace: (query, options) => {
const [pathname] = split(Router.asPath)
Expand All @@ -97,9 +105,17 @@ export const GeschichteForNextjs: FC<Props> = ({
}

if (routerReplace) {
return routerReplace(Router.route, { pathname, query }, routerOptions)
return routerReplace(
{ pathname, query: Router.query },
{ pathname, query },
routerOptions
)
}
return Router.replace(Router.route, { pathname, query }, routerOptions)
return Router.replace(
{ pathname, query: Router.query },
{ pathname, query },
routerOptions
)
},
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 0739767

Please sign in to comment.