The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Move props.modal to client component
Steven Tey73cc86ba36a6
diff --git a/app/dub.sh/layout.tsx b/app/dub.sh/layout.tsxindex 7b4066d836..8166d63c65 100644--- a/app/dub.sh/layout.tsx+++ b/app/dub.sh/layout.tsx@@ -1,3 +1,4 @@+import Providers from "./providers";import Nav from "#/ui/home/nav";import Footer from "#/ui/home/footer";import Background from "#/ui/home/background";@@ -5,14 +6,14 @@ import MobileNav from "#/ui/home/nav-mobile";export default function MarketingLayout(props) {return (- <div className="flex min-h-screen flex-col">- {/* Only show stats modal if not on the /stats page */}- {props.children.props.childProp.segment !== "stats" && props.modal}- <MobileNav />- <Nav />- {props.children}- <Footer />- <Background />- </div>+ <Providers modal={props.modal}>+ <div className="flex min-h-screen flex-col">+ <MobileNav />+ <Nav />+ {props.children}+ <Footer />+ <Background />+ </div>+ </Providers>);}diff --git a/app/dub.sh/providers.tsx b/app/dub.sh/providers.tsxnew file mode 100644index 0000000000..3b36d6ab3d--- /dev/null+++ b/app/dub.sh/providers.tsx@@ -0,0 +1,23 @@+"use client";++import { useSelectedLayoutSegment } from "next/navigation";+import { ReactNode } from "react";+import { Toaster } from "sonner";++export default function Providers({+ modal,+ children,+}: {+ modal: ReactNode;+ children: React.ReactNode;+}) {+ const segment = useSelectedLayoutSegment();+ return (+ <div>+ {/* Only show stats modal if not on the /stats page */}+ {segment !== "stats" && modal}+ <Toaster />+ {children}+ </div>+ );+}diff --git a/app/layout.tsx b/app/layout.tsxindex ed06eefa92..99b05a27c4 100644--- a/app/layout.tsx+++ b/app/layout.tsx@@ -2,7 +2,6 @@ import "@/styles/globals.css";import { satoshi, inter } from "@/styles/fonts";import { Analytics } from "@vercel/analytics/react";import clsx from "clsx";-import { Providers } from "./providers";import { constructMetadata } from "@/lib/utils";export const metadata = constructMetadata({});@@ -15,10 +14,8 @@ export default function RootLayout({return (<html lang="en"><body className={clsx(satoshi.variable, inter.variable)}>- <Providers>- {children}- <Analytics />- </Providers>+ {children}+ <Analytics /></body></html>);diff --git a/app/providers.tsx b/app/providers.tsxdeleted file mode 100644index b9e836628a..0000000000--- a/app/providers.tsx+++ /dev/null@@ -1,12 +0,0 @@-"use client";--import { Toaster } from "sonner";--export function Providers({ children }: { children: React.ReactNode }) {- return (- <div>- <Toaster />- {children}- </div>- );-}diff --git a/app/ui/modal.tsx b/app/ui/modal.tsxindex ff7e39eb6b..6d9497ac1c 100644--- a/app/ui/modal.tsx+++ b/app/ui/modal.tsx@@ -97,7 +97,7 @@ export default function Modal({<motion.divref={mobileModalRef}key="mobile-modal"- className="group fixed inset-x-0 bottom-0 z-40 max-h-[80vh] w-screen cursor-grab active:cursor-grabbing md:hidden"+ className="group fixed inset-x-0 bottom-0 z-50 max-h-[80vh] w-screen cursor-grab active:cursor-grabbing md:hidden"initial={{ y: "100%" }}animate={controls}exit={{ y: "100%" }}@@ -120,7 +120,7 @@ export default function Modal({<motion.divref={desktopModalRef}key="desktop-modal"- className="fixed inset-0 z-40 hidden min-h-screen items-center justify-center md:flex"+ className="fixed inset-0 z-50 hidden min-h-screen items-center justify-center md:flex"initial={{ scale: 0.95 }}animate={{ scale: 1 }}exit={{ scale: 0.95 }}@@ -136,7 +136,7 @@ export default function Modal({<motion.divid="modal-backdrop"key="backdrop"- className="fixed inset-0 z-30 bg-gray-100 bg-opacity-10 backdrop-blur"+ className="fixed inset-0 z-40 bg-gray-100 bg-opacity-10 backdrop-blur"initial={{ opacity: 0 }}animate={{ opacity: 1 }}exit={{ opacity: 0 }}diff --git a/app/ui/stats/toggle.tsx b/app/ui/stats/toggle.tsxindex 3fdec1463c..d48ead175a 100644--- a/app/ui/stats/toggle.tsx+++ b/app/ui/stats/toggle.tsx@@ -40,7 +40,7 @@ export default function Toggle() {<divclassName={`z-10 mb-5 ${basePath.startsWith("/stats")- ? `top-0 ${!modal ? "md:top-16" : ""}`+ ? `top-0 ${!modal ? "md:top-14" : ""}`: "top-[6.95rem]"} sticky bg-gray-50 py-3 md:py-5 ${scrolled && !modal ? "shadow-md" : ""