Skip to content

Commit

Permalink
Merge pull request #242 from alephium/update-web3-react
Browse files Browse the repository at this point in the history
Update web3-react
  • Loading branch information
polarker authored Sep 1, 2023
2 parents f854cf4 + 528c7aa commit 9e9dcb4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docs/dapps/dapp-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>Connecting</div>
if (connectionStatus === 'disconnected') return <div>Disconnected</div>

// connected
return <div>{account}</div>
}
```

If the return value is `undefined`, it indicates that the wallet is not connected. The returned wallet has the following fields:
Expand Down Expand Up @@ -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 (
<AlephiumConnectButton.Custom>
{({ isConnected, show, address }) => {
{({ isConnected, disconnect, show, account }) => {
return isConnected ? (
<button onClick={disconnect}>
Disconnect
Expand Down

0 comments on commit 9e9dcb4

Please sign in to comment.