Skip to content

useAdapter

function useAdapter(): Pick<FilecoinContextType, "reconnecting" | "adapter" | "network" | "loading" | "error">;

Defined in: packages/iso-filecoin-react/src/wallet-provider.js:313

Hook to access the current wallet adapter and its state

Returns

Pick<FilecoinContextType, "reconnecting" | "adapter" | "network" | "loading" | "error">

Wallet adapter state

Example

import {
function useAdapter(): Pick<FilecoinContextType, "adapter" | "error" | "loading" | "network" | "reconnecting">

Hook to access the current wallet adapter and its state

@example

import { useAdapter } from 'iso-filecoin-react'
function App() {
const { adapter, error, loading } = useAdapter()
if (loading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
return <div>Current adapter: {adapter?.name}</div>
}

@returnsWallet adapter state

useAdapter
} from 'iso-filecoin-react'
function
function App(): React.JSX.Element
App
() {
const {
const adapter: WalletAdapter | undefined

Currently selected wallet adapter

adapter
,
const error: Error | undefined

Last error that occurred on the selected adapter

error
,
const loading: boolean

Provider is checking adapters support

loading
} =
function useAdapter(): Pick<FilecoinContextType, "adapter" | "error" | "loading" | "network" | "reconnecting">

Hook to access the current wallet adapter and its state

@example

import { useAdapter } from 'iso-filecoin-react'
function App() {
const { adapter, error, loading } = useAdapter()
if (loading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
return <div>Current adapter: {adapter?.name}</div>
}

@returnsWallet adapter state

useAdapter
()
if (
const loading: boolean

Provider is checking adapters support

loading
) return <
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>Loading...</
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>
if (
const error: Error | undefined

Last error that occurred on the selected adapter

error
) return <
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>Error: {
const error: Error

Last error that occurred on the selected adapter

error
.
Error.message: string
message
}</
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>
return <
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>Current adapter: {
const adapter: WalletAdapter | undefined

Currently selected wallet adapter

adapter
?.
WalletAdapter.name: string | undefined

Human readable wallet name

name
}</
React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>
}