From bedb53fc957039d1efd202947148cb3db154f351 Mon Sep 17 00:00:00 2001 From: Tina Zheng Date: Tue, 4 Jun 2024 16:25:57 -0400 Subject: [PATCH 1/7] feat: add error boundary by id --- examples/ui-demo/src/app/page.tsx | 41 +++++++++-------- examples/ui-demo/src/app/providers.tsx | 5 ++- .../src/react/components/auth/card/index.tsx | 10 ++++- .../src/react/components/notification.tsx | 29 ++++++++++++ packages/alchemy/src/react/context.tsx | 44 ++++++++++++++++++- packages/alchemy/src/tailwind/theme.ts | 3 ++ packages/alchemy/src/tailwind/types.ts | 3 ++ 7 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 packages/alchemy/src/react/components/notification.tsx diff --git a/examples/ui-demo/src/app/page.tsx b/examples/ui-demo/src/app/page.tsx index 8d8c08163a..ce7df24801 100644 --- a/examples/ui-demo/src/app/page.tsx +++ b/examples/ui-demo/src/app/page.tsx @@ -11,7 +11,7 @@ import { import { ChevronRight } from "@/src/components/icons/chevron"; import { MailIcon } from "@/src/components/icons/mail"; import { Input, useLogout } from "@alchemy/aa-alchemy/react"; -import { useMemo } from "react"; +import { useMemo, useRef } from "react"; export default function Home() { // const [darkMode, setDarkMode] = useState(false) @@ -19,15 +19,14 @@ export default function Home() { () => [[{ type: "email", hideButton: true }], [{ type: "passkey" }]], [] ); + const errorBoundary = useRef(null); const { openAuthModal } = useAuthModal(); const user = useUser(); const { logout } = useLogout(); return ( <> -
+

Buttons

@@ -65,20 +64,26 @@ export default function Home() {

Auth

-
- {!user ? ( - - ) : ( -
- Logged in as {user.email ?? "anon"} - -
- )} +
+
+ {!user ? ( + + ) : ( +
+ Logged in as {user.email ?? "anon"} + +
+ )} +
+
-
+
+
+
+ {!user ? ( + + ) : ( +
+ Logged in as {user.email ?? "anon"} + +
+ )} +
+ {error && error.message && ( +
+ {error.message}
)}
-
- - )}
Having trouble?