Next.js Discord

Discord Forum

some pages caching until full reload

Unanswered
Elite posted this in #help-forum
Open in Discord
so i have a table and some items that users can add to their list. so on the /explore page you add things to your list. and you go to /my-list to view your list (added items)|

problem is the /my-list doesnt update until i do a full page reload (CTRL + R). ive set my links in the navbar to prefetch={false} and i did export const dynamic = "force-dynamic"; at the top of the page.tsx

confused as to why this is happening.

26 Replies

not sure if you're facing the same challenge as I was @Elite , but have you tried using Templates?

https://nextjs-forum.com/post/1255626619247136919
any other ideas @decorum ?
Palomino
Think so, you are using a proper state management solution that allows state to be shared across different pages. Common solutions include using React Context, Redux, or even Zustand. This way, when you add an item on the /explore page, the state will be updated globally, and the /my-list page will react to those changes.
Palomino
At first, You have to ensure that the data fetching on the /my-list page happens on the client side to allow dynamic updates without a page reload.
And then confirm of use a state management solution (like React's Context API or a global state library like Redux) to manage the state of the user's list across different components.
Palomino
In the server-side, For a more real-time update approach, consider using WebSockets or Server-Sent Events (SSE) to push updates from the server to the client whenever the list changes.
lol
same thing though
im literally pulling from db on page load
so
should i check if the drizzle query is cached
never mind got it working
i made all the fetch data functions server actions and it works now
I'm curious if a revalidatePath('/my-list') as part of a server action when you add things on '/explore' would have helped, too.

It genuinely sounds like you're doing exactly what Lee Rob does in his Server Actions tutorial video --> https://youtu.be/dDpZfOQBMaU?si=YOnqecXTOsIcfWqd
Not that using Actions to fetch data is bad or anything, but it can lead to unexpected behavior as well (at least it did for my team)
hmm alr ty