-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: connector connect and disconnect
- Loading branch information
Showing
4 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@starknet-react/core': patch | ||
--- | ||
|
||
Improve connector disconnect |
16 changes: 12 additions & 4 deletions
16
examples/starknet-react-next/src/components/ConnectWallet.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import { useStarknet, InjectedConnector } from '@starknet-react/core' | ||
import { useStarknet } from '@starknet-react/core' | ||
|
||
export function ConnectWallet() { | ||
const { account, connect, disconnect } = useStarknet() | ||
const { account, connect, disconnect, connectors } = useStarknet() | ||
|
||
if (account) { | ||
return ( | ||
<div> | ||
<p>Account: {account}</p> | ||
<button onClick={() => disconnect(new InjectedConnector())}>Disconnect</button> | ||
<button onClick={() => disconnect()}>Disconnect</button> | ||
</div> | ||
) | ||
} | ||
|
||
return <button onClick={() => connect(new InjectedConnector())}>Connect</button> | ||
return ( | ||
<> | ||
{connectors.map((connector, idx) => ( | ||
<button key={idx} onClick={() => connect(connector)}> | ||
Connect | ||
</button> | ||
))} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters