Next.js Discord

Discord Forum

Calling router.replace() with new query params no longer updates with the correct data

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
We have a pagination hook that will manage query params related to pagination. Whenevery they change, we use

startTransition(() => {
    const paramsString = params.toString();

    replace(`${pathname}?${paramsString}`, { scroll: false }); //router.refresh from next/navigation
});


Server page code triggers. I have console logged out the data on the page.tsx just before the return Element and the data is correct. It has correctly grabbed the appropriate query params and filtered the data on it.

To eliminate any errors with my list components, I have done the simplest of list which is

{systems?.map((project) => project.name)}


On the page.tsx. That code does not update either.

I know the rest of the code is fine, b/c if I refresh the page manually, it results in the correct output. So that aligning with the server logging out the correct data tells me Next is just ignoring the refreshed data.

To complicate this further, if I use the search input on our table, it works! lol. This search input ALSO updates the query params and calls router.refresh (it's using the same hook)

2 Replies

GharialOP
I should also note that this code used to work. I have tried using older package.json versions but the issue remains. So I'm just lost at this point.
GharialOP
I have updated reset to refresh and it's working. I guess something changed internally in next that made reset no longer work (except for the query param 'search'????)? And I swear I tried refresh when I originally wrote this component and it didn't work which is why I used reset.