Learn how to implement pagination or filtering functionality in Next.js
P粉517814372
P粉517814372 2023-08-14 20:23:46
0
1
711
<p>I'm looking for a solution to implement paging or filtering in my web application using traditional page routing methods. Do I need to use client side data fetching? When the query string changes, it will not cause the page content to be re-rendered. I don't want to use SSG to get the entire data and paginate it on the client side. Can you provide some advice or examples of how to achieve this effectively? There are currently limited resources on this topic and I would like to be able to handle dynamic data changes without affecting performance. </p> <p>Tried passing the query string to getServerSideProps but it only gets the data on refresh. The page should show filtered/paginated content immediately on button click. </p> <p>Please do not leave negative comments about this. If you need more information, please ask in the comments. </p>
P粉517814372
P粉517814372

reply all(1)
P粉477369269

I solved this problem. For those wondering, I actually made a mistake. I put shallow: true inside router.push. So when I change the query string, my page doesn't re-render. When you change the query string, be sure to put shallow: false inside router.push. Below is an example:

router.push({ 
    pathname: router.pathname, 
    query: { ...router.query } }, 
    undefined, 
    { 
       shallow: false
    }
);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template