From d0bb08c6ec701a4384d796ea9c426fed7d9b03d9 Mon Sep 17 00:00:00 2001 From: Cesar Alaestante Date: Wed, 13 Dec 2023 13:10:24 -0700 Subject: [PATCH] force dynamic, and ensure roomID is set --- examples/tiptap/src/app/page.tsx | 2 ++ examples/tiptap/src/app/r/[id]/page.tsx | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/tiptap/src/app/page.tsx b/examples/tiptap/src/app/page.tsx index 8765971..f37d46e 100644 --- a/examples/tiptap/src/app/page.tsx +++ b/examples/tiptap/src/app/page.tsx @@ -1,6 +1,8 @@ import { nanoid } from "nanoid"; import { redirect } from "next/navigation"; +export const dynamic = "force-dynamic"; + function Page() { redirect("/r/" + nanoid(6)); } diff --git a/examples/tiptap/src/app/r/[id]/page.tsx b/examples/tiptap/src/app/r/[id]/page.tsx index aa214fa..2fc742d 100644 --- a/examples/tiptap/src/app/r/[id]/page.tsx +++ b/examples/tiptap/src/app/r/[id]/page.tsx @@ -1,12 +1,19 @@ "use client"; import { TextEditor } from "@/components/TextEditor"; +import { useEffect, useState } from "react"; export default function Home() { - const [, , roomID] = location.pathname.split("/"); + const [roomID, setRoomID] = useState(null); + useEffect(() => { + const [, , roomID] = location.pathname.split("/"); + setRoomID(roomID); + }, []); return ( -
- -
+ roomID && ( +
+ +
+ ) ); }