From 3b7bb1e1821984e6d912a92cef702d84e93b6b9f Mon Sep 17 00:00:00 2001 From: Cheng Wang Date: Fri, 1 Sep 2023 12:01:07 +0200 Subject: [PATCH 1/2] Update web3-react --- docs/dapps/dapp-recipes.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/dapps/dapp-recipes.md b/docs/dapps/dapp-recipes.md index cca4646d..936927b8 100644 --- a/docs/dapps/dapp-recipes.md +++ b/docs/dapps/dapp-recipes.md @@ -125,7 +125,15 @@ The `@alephium/web3-react` package provides several hooks to facilitate the deve ```typescript import { useWallet, Wallet } from '@alephium/web3-react' -const wallet: Wallet | undefined = useWallet() +function Component() { + const { account, connectionStatus } = useWallet() + + if (connectionStatus === 'connecting') return
Connecting
+ if (connectionStatus === 'disconnected') return
Connecting
+ + // connected + return
{account}
+} ``` If the return value is `undefined`, it indicates that the wallet is not connected. The returned wallet has the following fields: @@ -188,17 +196,12 @@ const nodeProvider = new NodeProvider('node-url', undefined, retryFetch) you can also use the `AlephiumConnectButton.Custom` to customize the style of the connect button: ```typescript -import { AlephiumConnectButton, useConnect } from '@alephium/web3' +import { AlephiumConnectButton } from '@alephium/web3' function CustomWalletConnectButton = () => { - const { disconnect } = useConnect({ - addressGroup: 0, - networkId: 'mainnet' - }) - return ( - {({ isConnected, show, address }) => { + {({ isConnected, disconnect, show, address }) => { return isConnected ? (