mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(settings): stop the integrations notification card hydrating from null
NotificationStatusCard read useAuth().isAuthenticated, which is false during SSR and true on the client, so the card rendered null on the server and a loading card on first client paint — a tree-shape change React reported as a hydration mismatch on every authenticated load of the integrations page, regenerating the subtree and dropping the channel controls' handlers. Gate the card behind the shared useMounted() hydration probe so the server and the first client paint agree (both render null); the real status loads as an ordinary post-hydration update. Fold the settings shell's own inline copy of the probe onto the same hook.
This commit is contained in:
1 parent
d0b4b1e4cd
commit
a31711699c
3 files changed
+25
-15
No files matched your search
@@ -35,6 +35,14 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({ isAuthenticated: true }),
|
||||
}));
|
||||
|
||||
// The card gates its auth/loading branches behind `useMounted()` so SSR and
|
||||
// the first client paint render identically (`null`) and avoid a React #418
|
||||
// hydration mismatch. These tests assert the POST-hydration content tree, so
|
||||
// pin the probe to `true` — the state the card reaches once hydrated.
|
||||
vi.mock("@/hooks/use-mounted", () => ({
|
||||
useMounted: () => true,
|
||||
}));
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { NotificationStatusCard } from "../notification-status-card";
|
||||
|
||||
|
||||
Reference in new issue
Block a user