WalletData Component
In the example crowdfund dapp, theWalletData component plays a key role in wallet integration. Let’s break down the code and understand its functionality:
/components/moleculres/wallet-data/index.tsx
- The
mountedvariable is obtained using theuseIsMountedhook, indicating whether the component is currently mounted or not. - The
useAccounthook is used to fetch the user’s account data, and thedataproperty is destructured from the result. - Conditional rendering is used to display different content based on the component’s mount status and the availability of account data.
- If the component is mounted and the account data is available, the user’s wallet data is displayed. This includes the account’s display name.
- If the component is not mounted or the account data is not available, a
ConnectButtoncomponent is rendered, allowing the user to connect with Freighter.