#Streaming and changing search params

1 messages · Page 1 of 1 (latest)

keen gazelle
#

Hello

I implemented data in a table by using the nextjs capabilities of streaming (unawaited promise + use()).

When data is loading I have a suspense that is triggered to give the user a skeleton.

The problem is it only triggers on the first load. When I change the search params (page, page size etc) it doesn't trigger the suspense anymore.

high topazBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

south gate
#

The problem is it only triggers on the first load. When I change the search params (page, page size etc) it doesn't trigger the suspense anymore.
which is good right? the data is already loaded

keen gazelle
#

Not when you change the tables page for exemple

#

The promise is reexecuted

#

But suspense is not triggered

south gate
#

ye but promises resolves in 1ms sooo

keen gazelle
#

Even if I put a breakpoint server side

#

It just stays frozen

south gate
#

how do you change the serachparams?

keen gazelle
#

With a next/linq by just providing the query parameter

south gate
#

no i mean how do you navigate from one search param to another search param

keen gazelle
#

Yep

south gate
#

i mean how

#

via redirect() or via router.push, or <Link> or <a>

keen gazelle
#

<Link query={{ ...previousQueries, page: new page }} />

#

Something like that

#

So next routing navigation that triggers correctly my async page flow.

south gate
#

query is not a valid Link prop

keen gazelle
#

Sorry in the href prop

#

Like that

#

But without any pathname

keen gazelle
#

It is weird, when I click on the next link, the address refresh is only made a the moment where the new data is coming.
So I guess it is normal my keyed suspense on the property doesn't retriggere the suspense.
But I don't know where I'm going wrong.

keen gazelle
#

RESOLUTION =======>
Using a key on a suspense allows it to know, although the suspense has been resolved and data has arrived initially, there is a new one. I used a search params hash to signal it.

BUT

Navigation in nextjs seems to be pessimistic by default. So the address bar only refreshes when the tree has been updated.

The solution is during the navigation with the Link element, specify "prefetch={false}" so that internally it navigates optimistically and the key updates directly on the suspense.