Next.js Discord

Discord Forum

Create query params with an on click handler

Unanswered
Largehead hairtail posted this in #help-forum
Open in Discord
Largehead hairtailOP
I want to create two buttons. Each button will change the query params to something. In my page.js I want to get the query params from the props and do something with them.
Problem is it is very buggy. When I click on each button it does update the url and my page gets the updated query but when I click between them a few times, it stops to update on my page. On the other hand if I have a text input and change the query params with on change, I always get the updated query params. With on click it's not consistently working.
Can anybody shed some light on why is this the case?

1 Reply

Largehead hairtailOP
And the reason I want to do this because depending on what I click I want my app page router to get the params and do a fetch depending on what the params are. Like the video I posted. Would this be the next js 14 way to do so?