Skip to content

Commit

Permalink
fix: πŸ› Sometimes form editor page not loading
Browse files Browse the repository at this point in the history
Moved clerk provider to root layout, and make root page force static
rendered

βœ… Closes: #206
  • Loading branch information
growupanand committed Mar 3, 2024
1 parent 6df1fcb commit c46eab4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 33 deletions.
9 changes: 0 additions & 9 deletions apps/web/src/app/(landingPage)/_components/userButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@ import { Skeleton } from "@convoform/ui/components/ui/skeleton";
import { LayoutDashboard } from "lucide-react";

import { LinkN } from "../../../components/common/linkN";
import { AuthProvider } from "../../../components/providers/authProvider";
import { SignInButton } from "./signInButton";

export default function UserSignInButton() {
return (
<AuthProvider>
<UserSignInButtonInner />
</AuthProvider>
);
}

function UserSignInButtonInner() {
const { isSignedIn } = useAuth();

if (isSignedIn) {
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/app/(landingPage)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { Footer } from "@/app/(landingPage)/_components/footer";
import { Header } from "@/app/(landingPage)/_components/header";
import { SectionShell } from "./_components/sectionShell";

/**
* We need to force static rendering for our homepage, by setting `dynamic` to `force-static`
* Because we used <ClerkProvider> in root Layout, Which make whole child tree to be dynamic rendered.
*/
export const dynamic = "force-static";

type Props = {
children: React.ReactNode;
};
Expand Down
9 changes: 0 additions & 9 deletions apps/web/src/app/(protectedPage)/layout.tsx

This file was deleted.

25 changes: 11 additions & 14 deletions apps/web/src/app/auth/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ import { ClerkLoading } from "@clerk/nextjs";

import BrandName from "@/components/common/brandName";
import Spinner from "@/components/common/spinner";
import { AuthProvider } from "@/components/providers/authProvider";

type Props = {
children: React.ReactNode;
};

export default function Layout({ children }: Readonly<Props>) {
return (
<AuthProvider>
<main className="container max-w-[900px]">
<nav className="mt-5 flex items-center justify-center p-3">
<BrandName className="text-3xl" />
</nav>
<ClerkLoading>
<div className="flex w-full justify-center">
<Spinner label="Please wait..." />
</div>
</ClerkLoading>
{children}
</main>
</AuthProvider>
<main className="container max-w-[900px]">
<nav className="mt-5 flex items-center justify-center p-3">
<BrandName className="text-3xl" />
</nav>
<ClerkLoading>
<div className="flex w-full justify-center">
<Spinner label="Please wait..." />
</div>
</ClerkLoading>
{children}
</main>
);
}
5 changes: 4 additions & 1 deletion apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Viewport } from "next";
import { Toaster } from "@convoform/ui/components/ui/toaster";

import GoogleAnalytics from "@/components/googleAnalytics";
import { AuthProvider } from "@/components/providers/authProvider";
import { TRPCReactProvider } from "@/trpc/react";
import { roboto } from "./fonts";

Expand Down Expand Up @@ -74,7 +75,9 @@ export default function RootLayout({
{process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS ? (
<GoogleAnalytics ga_id={process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS} />
) : null}
<TRPCReactProvider>{children}</TRPCReactProvider>
<TRPCReactProvider>
<AuthProvider>{children}</AuthProvider>
</TRPCReactProvider>
<Toaster />
</body>
</html>
Expand Down

0 comments on commit c46eab4

Please sign in to comment.