Next.js Discord

Discord Forum

Revalidation after client side navigation

Unanswered
Pyrenean Sheepdog posted this in #help-forum
Open in Discord
Avatar
Pyrenean SheepdogOP
Hey everyone, I can't find a solution for this. I have a component where I'm checking the filters and updating the searchParams in URL. In the ProjectsPage I have a Link which navigates me back to the same URL without searchParams. I also have attached onClick prop with revalidation of /projects path, but the revalidation doesn't seem to be done. Do you have any idea why? Or is there a better way to do this? Thanks 😊
Image
Image
Image

5 Replies

Avatar
I can only talk from personal experience: when you change your searchparams and revalidating it at the same time, the content won't be updated correctly.

A possible solution would be to handle both separate. So handle either search params change first or the revalidation first
Avatar
Pyrenean SheepdogOP
How would you do that?
I tried it this way too, but no progress.

<Button className="hover:text-white" onPress={() => { router.push("/projects"); setTimeout(() => { revalidateProjects(); , 50); }} > <RiCloseFill /> </Button>
Avatar
Pyrenean SheepdogOP
Maybe some caching issue?
Avatar
idk. I just stopped using searchparams. I never found a way to do that.
However: maybe we find a work around what do you expect your button click shoud do?