revalidatePath("/") re-renders layout with correct data but not child client components
Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
I have a layout implemented as a server component that provides data to client component( react context). The client component serves the cart data to any component that subscribes to it.
When the cart is fulfilled and payed for at /checkout (server component) through a server action. Upon success I remove cartId from cookies and revalidate the path "/". When the page is re rendered it sees there is no cartId in the cookie, and here is where things get confusing, since there is no cartId there is no cart data that should be passed to client components however in the client component it looks like the cart is still populate with stale data?
My question is: how can I update the trigger a successful re-render on the client component with the fresh data?
Thanks!
When the cart is fulfilled and payed for at /checkout (server component) through a server action. Upon success I remove cartId from cookies and revalidate the path "/". When the page is re rendered it sees there is no cartId in the cookie, and here is where things get confusing, since there is no cartId there is no cart data that should be passed to client components however in the client component it looks like the cart is still populate with stale data?
My question is: how can I update the trigger a successful re-render on the client component with the fresh data?
Thanks!