fix(NodeSwitcher): avoid SSR hydration error by deferring portal creation
Build and Deploy / Build and Push Docker Image (push) Successful in 1m59s

This commit is contained in:
2026-08-08 03:11:47 +08:00
parent e2063dbeb8
commit 8be7e8ad2f
@@ -17,8 +17,13 @@ export function NodeSwitcher() {
const [isMaster, setIsMaster] = useState(false)
const [open, setOpen] = useState(false)
const [menuStyle, setMenuStyle] = useState<React.CSSProperties>({})
const [mounted, setMounted] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
useEffect(() => {
setMounted(true)
}, [])
const fetchNodes = useCallback(async () => {
try {
const res = await getNodes()
@@ -157,6 +162,7 @@ export function NodeSwitcher() {
</button>
{open &&
mounted &&
createPortal(
<div className="ui-select-menu" style={menuStyle}>
{allOptions.map((opt) => (