#query params aren't working before refresh

4 messages · Page 1 of 1 (latest)

red isle
#

So weird issue here. I'm trying to do serverside pagination.

Frontend:

        let prevButton = <Link href={{pathname:"links", query:{after:props.prev}}}>Previous 25</Link>
        let nextButton = <Link href={{pathname:"links", query:{after:props.next}}}>next 25</Link>

        if (props.prev < 0){
            prevButton = <></>
        }

        if (links.length < 25){
            nextButton = <></>
        }
        nextAndPrevButtons = <>{prevButton}{nextButton}</>
        
    }```
backend:
```ts
getServerSideProps({req, query}:any){
... 
after = parseInt(query.after as string)
....
let linkData:LinkWithViews[] = await prisma.generatedLink.findMany({
        skip:after,
        take:25,
        where:{
            userID:user.id
        },
  ...

So when I try this, what ends up happening is the URL changes, and "After" changes (as viewed by console.log) but the actual findmany collected by prisma appear to be the same. Then I refresh and everything works. So the issue basically is that it will appear to navigate to the new page/pagination index, gather the correct data, but the links are the same as before (you can click "next" a dozen times until after says 2000 or something and it will still be the same). So I'm seeing the page as if it had a previous pagination. But refreshing it will fix this problem.
Any idea what's going on here?

pure swiftBOT
#

🔎 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)

red isle
#

ok, looks like the state just isn't updating when I navigate this way. Any idea how to force the state to update?

#

esp from backend