From 8be7e8ad2f5dd20ffb1bed477584c559ae8d45ec Mon Sep 17 00:00:00 2001 From: TaskPool Date: Sat, 8 Aug 2026 03:11:47 +0800 Subject: [PATCH] fix(NodeSwitcher): avoid SSR hydration error by deferring portal creation --- web/src/components/business/NodeSwitcher.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/src/components/business/NodeSwitcher.tsx b/web/src/components/business/NodeSwitcher.tsx index d6ffe0b..d8c0444 100644 --- a/web/src/components/business/NodeSwitcher.tsx +++ b/web/src/components/business/NodeSwitcher.tsx @@ -17,8 +17,13 @@ export function NodeSwitcher() { const [isMaster, setIsMaster] = useState(false) const [open, setOpen] = useState(false) const [menuStyle, setMenuStyle] = useState({}) + const [mounted, setMounted] = useState(false) const buttonRef = useRef(null) + useEffect(() => { + setMounted(true) + }, []) + const fetchNodes = useCallback(async () => { try { const res = await getNodes() @@ -157,6 +162,7 @@ export function NodeSwitcher() { {open && + mounted && createPortal(
{allOptions.map((opt) => (