diff --git a/src/renderer/src/components/settings/SshTargetCard.tsx b/src/renderer/src/components/settings/SshTargetCard.tsx index c1b0c1393..d794c64b9 100644 --- a/src/renderer/src/components/settings/SshTargetCard.tsx +++ b/src/renderer/src/components/settings/SshTargetCard.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useCallback, useRef, useState } from 'react' import { CircleStop, Loader2, @@ -87,11 +87,10 @@ export function SshTargetCard({ const removeInFlight = busyAction === 'remove' const mountedRef = useRef(true) - useEffect(() => { - mountedRef.current = true - return () => { - mountedRef.current = false - } + const handleCardRef = useCallback((node: HTMLDivElement | null): void => { + // Why: SSH target actions can resolve after the card is removed; the root + // ref gives async completions the same stale-write guard without an Effect. + mountedRef.current = node !== null }, []) const clearActionInFlight = (): void => { @@ -226,7 +225,10 @@ export function SshTargetCard({ ) return ( -