useConnect
useConnect():
UseMutationResult<AccountNetwork,Error, {adapter:WalletAdapter; },void> &Pick<FilecoinContextType,"adapter"|"adapters"|"loading">
Defined in: packages/iso-filecoin-react/src/wallet-provider.js:423
Hook to connect a wallet adapter
Returns
Section titled “Returns”UseMutationResult<AccountNetwork, Error, { adapter: WalletAdapter; }, void> & Pick<FilecoinContextType, "adapter" | "adapters" | "loading">
Connection mutation and state
Example
Section titled “Example”import { function useConnect(): UseMutationResult<AccountNetwork, Error, { adapter: WalletAdapter;}, void> & Pick<FilecoinContextType, "adapters" | "adapter" | "loading">
Hook to connect a wallet adapter
useConnect } from 'iso-filecoin-react'
function function App(): JSX.Element
App() { const { const adapters: WalletAdapter[]
List of available wallet adapters
adapters, const error: Error | null
The error object for the mutation, if an error was encountered.
- Defaults to
null.
error, mutate: UseMutateFunction<AccountNetwork, Error, { adapter: WalletAdapter;}, void>
The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
mutate: const connect: UseMutateFunction<AccountNetwork, Error, { adapter: WalletAdapter;}, void>
The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
connect, const isPending: boolean
A boolean variable derived from status.
true if the mutation is currently executing.
isPending } = function useConnect(): UseMutationResult<AccountNetwork, Error, { adapter: WalletAdapter;}, void> & Pick<FilecoinContextType, "adapters" | "adapter" | "loading">
Hook to connect a wallet adapter
useConnect()
return ( <JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div> {const adapters: WalletAdapter[]
List of available wallet adapters
adapters.Array<WalletAdapter>.map<JSX.Element>(callbackfn: (value: WalletAdapter, index: number, array: WalletAdapter[]) => JSX.Element, thisArg?: any): JSX.Element[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(adapter: WalletAdapter
adapter => ( <JSX.IntrinsicElements.button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button Attributes.key?: Key | null | undefined
key={adapter: WalletAdapter
adapter.WalletAdapter.name: string
Human readable wallet name
name} DOMAttributes<HTMLButtonElement>.onClick?: MouseEventHandler<HTMLButtonElement> | undefined
onClick={() => const connect: (variables: { adapter: WalletAdapter;}, options?: MutateOptions<AccountNetwork, Error, { adapter: WalletAdapter;}, void> | undefined) => void
The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
connect({ adapter: WalletAdapter
adapter })} ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
disabled={const isPending: boolean
A boolean variable derived from status.
true if the mutation is currently executing.
isPending} > Connect {adapter: WalletAdapter
adapter.WalletAdapter.name: string
Human readable wallet name
name} </JSX.IntrinsicElements.button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button> ))} {const error: Error | null
The error object for the mutation, if an error was encountered.
- Defaults to
null.
error && <JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div>Error: {const error: Error
The error object for the mutation, if an error was encountered.
- Defaults to
null.
error.Error.message: string
message}</JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div>} </JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div> )}