Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix hydration error on dashboard page

Luke Vella69bebe0917f7
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/password-setup-alert.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/password-setup-alert.tsx
index 9e849a493..b2269362c 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/password-setup-alert.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/password-setup-alert.tsx
@@ -3,57 +3,82 @@ import { usePostHog } from "@rallly/posthog/client";
import { Alert, AlertDescription, AlertTitle } from "@rallly/ui/alert";
import { Button } from "@rallly/ui/button";
import { KeyRoundIcon } from "lucide-react";
+import { AnimatePresence } from "motion/react";
+import * as m from "motion/react-m";
+import dynamic from "next/dynamic";
import Link from "next/link";
import { useLocalStorage } from "react-use";
import { Trans } from "@/i18n/client";
-export function PasswordSetupAlert() {
- const [value, setValue] = useLocalStorage<string>("password_setup_dismissed");
- const posthog = usePostHog();
+export const PasswordSetupAlert = dynamic(
+ () => Promise.resolve(PasswordSetupAlertInner),
+ { ssr: false },
+);
- if (value) {
- return null;
- }
+function PasswordSetupAlertInner() {
+ const [dismissed, setDismissed] = useLocalStorage<string>(
+ "password_setup_dismissed",
+ );
+ const posthog = usePostHog();
return (
- <Alert>
- <KeyRoundIcon />
- <AlertTitle>
- <Trans
- i18nKey="setupPasswordAlertTitle"
- defaults="Login quicker with a password"
- />
- </AlertTitle>
- <AlertDescription>
- <p>
- <Trans
- i18nKey="setupPasswordAlertDesc"
- defaults="Set up a password to make logging in faster and more convenient."
- />
- </p>
- <div className="mt-4 flex items-center gap-2">
- <Button
- variant="primary"
- onClick={() => {
- posthog.capture("space_dashboard:password_setup_button_click");
- }}
- asChild
- >
- <Link href="/settings/security">
- <Trans i18nKey="setupPasswordButton" defaults="Set up password" />
- </Link>
- </Button>
- <Button
- variant="ghost"
- onClick={() => {
- setValue("1");
- posthog.capture("space_dashboard:password_setup_dismissed");
- }}
- >
- <Trans i18nKey="dismissPasswordSetup" defaults="Don't show again" />
- </Button>
- </div>
- </AlertDescription>
- </Alert>
+ <AnimatePresence initial={true}>
+ {!dismissed ? (
+ <m.div
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: "auto", opacity: 1 }}
+ exit={{ height: 0, opacity: 0 }}
+ style={{ overflow: "hidden" }}
+ >
+ <Alert>
+ <KeyRoundIcon />
+ <AlertTitle>
+ <Trans
+ i18nKey="setupPasswordAlertTitle"
+ defaults="Login quicker with a password"
+ />
+ </AlertTitle>
+ <AlertDescription>
+ <p>
+ <Trans
+ i18nKey="setupPasswordAlertDesc"
+ defaults="Set up a password to make logging in faster and more convenient."
+ />
+ </p>
+ <div className="mt-4 flex items-center gap-2">
+ <Button
+ variant="primary"
+ onClick={() => {
+ posthog.capture(
+ "space_dashboard:password_setup_button_click",
+ );
+ }}
+ asChild
+ >
+ <Link href="/settings/security">
+ <Trans
+ i18nKey="setupPasswordButton"
+ defaults="Set up password"
+ />
+ </Link>
+ </Button>
+ <Button
+ variant="ghost"
+ onClick={() => {
+ setDismissed("1");
+ posthog.capture("space_dashboard:password_setup_dismissed");
+ }}
+ >
+ <Trans
+ i18nKey="dismissPasswordSetup"
+ defaults="Don't show again"
+ />
+ </Button>
+ </div>
+ </AlertDescription>
+ </Alert>
+ </m.div>
+ ) : null}
+ </AnimatePresence>
);
}