Skip to content

Commit

Permalink
fix: refreshing in wallet component
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Aug 23, 2023
1 parent 4b09b3f commit 6c5d501
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions components/UI/wallets.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import styles from "../../styles/components/wallets.module.css";
import { Connector, useAccount, useConnectors } from "@starknet-react/core";
import Button from "./button";
Expand All @@ -15,9 +15,14 @@ const Wallets: FunctionComponent<WalletsProps> = ({
closeWallet,
hasWallet,
}) => {
const { connect, connectors } = useConnectors();
const { connect, connectors, refresh } = useConnectors();
const { account } = useAccount();

const myConnectors = useMemo(() => {
refresh();
return connectors;
}, [account]);

useEffect(() => {
if (account) {
closeWallet();
Expand Down Expand Up @@ -54,19 +59,19 @@ const Wallets: FunctionComponent<WalletsProps> = ({
</svg>
</button>
<p className={styles.menu_title}>You need a Starknet wallet</p>
{connectors.map((connector) => {
// if (connector.available()) {
return (
<div className="mt-5 flex justify-center" key={connector.id}>
<Button onClick={() => connectWallet(connector)}>
<div className="flex justify-center items-center">
<WalletIcons id={connector.id} />
{`Connect ${connector.name}`}
</div>
</Button>
</div>
);
// }
{myConnectors.map((connector) => {
if (connector.available()) {
return (
<div className="mt-5 flex justify-center" key={connector.id}>
<Button onClick={() => connectWallet(connector)}>
<div className="flex justify-center items-center">
<WalletIcons id={connector.id} />
{`Connect ${connector.name}`}
</div>
</Button>
</div>
);
}
})}
</div>
</Modal>
Expand Down

0 comments on commit 6c5d501

Please sign in to comment.