shallow:true
Answered
Short mackerel posted this in #help-forum
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
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
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
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
@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
If you are expecting the change on server component, you should use router.replace
@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.
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.
@Short mackerel 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.
Pass the data down to a useState hook in client component and filtering it
Or is it possible to pass the searchParams to the third-party api
@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.
Data should be re-fetched only if its changed in db.
@Short mackerel 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.
Yeah then you should pass the data to a useState hook
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
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
@Short mackerel 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
Pass the data from server component to a client component and put the data to a useState hook