From cf2676e3ad4941b1e79f481c27ad2c52e9317d68 Mon Sep 17 00:00:00 2001 From: David Heidrich Date: Wed, 19 Jul 2023 23:52:15 +0200 Subject: [PATCH] fix: fixed nextjs 13.x (pages) routing problems which would load a previous page when route queries are involved --- src/index.tsx | 1 - src/lib/adapters/nextjs/index.tsx | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 99699c1c..6aa26ff3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -23,4 +23,3 @@ export { createOrApplyPath, defaultSkipValue, } from './lib/utils.js' -export { default as default } from './lib/adapters/historyjs/index.js' diff --git a/src/lib/adapters/nextjs/index.tsx b/src/lib/adapters/nextjs/index.tsx index 2109704d..edd3ebb6 100644 --- a/src/lib/adapters/nextjs/index.tsx +++ b/src/lib/adapters/nextjs/index.tsx @@ -36,13 +36,13 @@ interface Props { // tslint:disable-next-line:no-mixed-interface readonly routerPush?: ( url: Url, - as: UrlObject, + as?: UrlObject, options?: TransitionOptions ) => Promise // tslint:disable-next-line:no-mixed-interface readonly routerReplace?: ( url: Url, - as: UrlObject, + as?: UrlObject, options?: TransitionOptions ) => Promise } @@ -83,14 +83,14 @@ export const GeschichteForNextjs: FC = ({ if (routerPush) { return routerPush( - { pathname, query: Router.query }, - { pathname, query }, + { query: Router.query }, + { query, pathname }, routerOptions ) } return Router.push( - { pathname, query: Router.query }, - { pathname, query }, + { query: Router.query }, + { query, pathname }, routerOptions ) }, @@ -104,13 +104,13 @@ export const GeschichteForNextjs: FC = ({ if (routerReplace) { return routerReplace( - { pathname, query: Router.query }, + { query: Router.query }, { pathname, query }, routerOptions ) } return Router.replace( - { pathname, query: Router.query }, + { query: Router.query }, { pathname, query }, routerOptions )