From 53decb09be8d397d5a4ee8b40162d524265b6ef1 Mon Sep 17 00:00:00 2001 From: steveluscher Date: Tue, 25 Jun 2024 23:02:33 +0000 Subject: [PATCH] When dismissing the error dialog for balance fetch failures, don't show it again --- examples/react-app/src/components/Balance.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/react-app/src/components/Balance.tsx b/examples/react-app/src/components/Balance.tsx index 6063357663ec..16b615b43edb 100644 --- a/examples/react-app/src/components/Balance.tsx +++ b/examples/react-app/src/components/Balance.tsx @@ -15,17 +15,22 @@ type Props = Readonly<{ account: UiWalletAccount; }>; +const seenErrors = new WeakSet(); + export function Balance({ account }: Props) { const { chain } = useContext(ChainContext); const { rpc, rpcSubscriptions } = useContext(RpcContext); const subscribe = useMemo(() => balanceSubscribe.bind(null, rpc, rpcSubscriptions), [rpc, rpcSubscriptions]); const { data: lamports, error } = useSWRSubscription({ address: address(account.address), chain }, subscribe); - if (error) { + if (error && !seenErrors.has(error)) { return ( <> { + seenErrors.add(error); + }} title="Failed to fetch account balance" />