Skip to content

Commit

Permalink
Fix isChainSupported in BalanceButton (#346)
Browse files Browse the repository at this point in the history
* Fix isChainSupported in BalanceButton

* Fix chain logo bad loading

* Fix "change in the order of Hooks"
  • Loading branch information
philogicae authored Feb 13, 2024
1 parent 5d27392 commit e565bfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/connectkit/src/components/BalanceButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Balance: React.FC<BalanceProps> = ({ hideIcon, hideSymbol }) => {

const { address, chain } = useAccount();
const chains = useChains();
const unsupported = useChainIsSupported(chain?.id);
const isChainSupported = useChainIsSupported(chain?.id);

const queryClient = useQueryClient();
const { data: blockNumber } = useBlockNumber({ watch: true });
Expand Down Expand Up @@ -105,7 +105,7 @@ export const Balance: React.FC<BalanceProps> = ({ hideIcon, hideSymbol }) => {
>
{!address || !isMounted || balance?.formatted === undefined ? (
<Container>
{!hideIcon && <Chain />}
{!hideIcon && <Chain id={chain?.id} />}
<span style={{ minWidth: 32 }}>
<PulseContainer>
<span style={{ animationDelay: '0ms' }} />
Expand All @@ -114,7 +114,7 @@ export const Balance: React.FC<BalanceProps> = ({ hideIcon, hideSymbol }) => {
</PulseContainer>
</span>
</Container>
) : unsupported ? (
) : !isChainSupported ? (
<Container>
{!hideIcon && <Chain id={chain?.id} />}
<span style={{ minWidth: 32 }}>???</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/src/hooks/useChainIsSupported.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useConfig } from 'wagmi';

export function useChainIsSupported(chainId?: number): boolean | null {
if (!chainId) return false;
const { chains } = useConfig();
if (!chainId) return false;
return chains.some((x) => x.id === chainId);
}

0 comments on commit e565bfa

Please sign in to comment.