Move mobile home client ref sync out of effect (#3247)

This commit is contained in:
Neil 2026-05-30 19:15:24 -07:00 committed by GitHub
parent 6399662fdf
commit 67f74a29a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -305,12 +305,12 @@ export default function HomeScreen() {
if (hosts.length > 0) primeHosts(hosts)
}, [hosts, primeHosts])
const allClientsRef = useRef<Array<{ hostId: string; client: RpcClient }>>([])
useEffect(() => {
allClientsRef.current = allClients.map((entry) => ({
hostId: entry.hostId,
client: entry.client
}))
}, [allClients])
// Why: the focus callback stays stable to avoid refetching on every
// client-store render, but it still needs the latest host clients.
allClientsRef.current = allClients.map((entry) => ({
hostId: entry.hostId,
client: entry.client
}))
// Why: hydrate the home page from a persisted snapshot on cold-start so
// Resume + Account-usage cards paint immediately with last-known data