Next.js Discord

Discord Forum

Realtime functionality with nextjs

Unanswered
Tan posted this in #help-forum
Open in Discord
TanOP
Page renders a table of placed orders and on clicking the orderId a modal with it's current status opens. From the admin dashboard I am able to update the status, it gets updated in the db but the modal UI is not working correctly, only the last entry somehow shows correct. I am unable to pinpoint the bug. The parent is a server component which maps over the orders. I am using supabase realtime for realtime status update notifications.

10 Replies

👋
import { useRouter } from "next/router";
export default function func() {
  const
    router = useRouter(),
    refreshData = () => {
      router.replace(router.asPath);
    };
this is where I setup refreshData()
so, for me I have getServerSideProps that provides initial context
when I change or update the initial context, refreshData allows this to be refreshed without actually page loading
edited code for clearness
this is how it looks:
pay attention to first modal, it gets updated.
TanOP
Ok I'll give it a try, thanks!
@Tan Ok I'll give it a try, thanks!
Goodluck!