Next.js Discord

Discord Forum

shallow:true

Answered
Short mackerel posted this in #help-forum
Open in Discord
Short mackerelOP
What is an alternative for it in app router?
Answered by Short mackerel
i am trying
https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#windowhistoryreplacestate

inside client component, but its parent which is RSC doesnt react on changed search params using {searchParams} props
View full answer

11 Replies

Short mackerelOP
i am trying
https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#windowhistoryreplacestate

inside client component, but its parent which is RSC doesnt react on changed search params using {searchParams} props
Answer
@Ray If you are expecting the change on server component, you should use router.replace
Short mackerelOP
yes, i am currently using it. But behavior is weird.
I wanna make client side filtering using data fetched by third-party API. In order to filter i use page's searchParams in RSC page. But it re-fetches the exact same data on every url change which i dont need.
@Ray Or is it possible to pass the searchParams to the third-party api
Short mackerelOP
yes, its possible but it will be server side filtering 🙂 I just wanna fetch data in RSC once and just filter the data on client.

Data should be re-fetched only if its changed in db.
and filtering it client side, either with other useState hook or url params
@Ray Yeah then you should pass the data to a useState hook
Short mackerelOP
What do you mean by passing data to a useState hook if its fetched in async RSC ?

Well, i need to provide some code

This is a function called in th RSC to fetch the data.

And second screen is a client component that changes URL search params.

Currently my UI is slowing down by fetching the whole data on every url's search params change