Skip to content

Commit

Permalink
[Portal] Update docs for useActiveWallet (#4352)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance the `useActiveWallet` hook by adding examples demonstrating its usage for account and network change events.

### Detailed summary
- Added examples for basic usage, account change event, multiple accounts changed event, and network change event in the `useActiveWallet` hook.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Sep 2, 2024
1 parent 3a55a7e commit aa556f1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/thirdweb/src/react/core/hooks/wallets/useActiveWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,40 @@ import { useConnectionManagerCtx } from "../../providers/connection-manager.js";
* A hook that returns the active wallet
* @returns The active `Wallet` or `undefined` if no active wallet is set.
* @example
*
* ### Basic usage
* ```jsx
* import { useActiveWallet } from "thirdweb/react";
*
* const wallet = useActiveWallet();
* ```
*
* ### Listen to account change event
* ```jsx
* const wallet = useActiveWallet();
*
* wallet?.subscribe("accountChanged", (account) => {
* console.log(account);
* });
* ```
*
* ### Listen to multiple accounts changed event
* ```jsx
* const wallet = useActiveWallet();
*
* wallet?.subscribe("accountsChanged", (addresses) => {
* console.log(addresses);
* });
* ```
*
* ### Listen to network change event
* ```jsx
* const wallet = useActiveWallet();
*
* wallet?.subscribe("chainChanged", (chain) => {
* console.log(chain);
* });
* ```
* @walletConnection
*/
export function useActiveWallet() {
Expand Down

0 comments on commit aa556f1

Please sign in to comment.