Connect 4337
Cometh ConnectCometh MarketplaceCometh Checkout
  • 🚀Quick start
    • What is Connect 4337
    • Getting started
    • Supported Networks
  • 🛠️CORE FEATURES
    • Create a Wallet
    • Send transactions
    • Go Gasless
    • Sign/Verify a message
    • Retrieve a wallet address
    • Handle owners
    • Import a safe into connect
  • 🥷ADVANCED
    • Session Keys
      • Tutorial
      • Policies
        • Sudo policy
        • Action policy
    • Social recovery
    • Add a passkey signer on a different OS
    • Capabilities
      • sendCalls
      • getCallsStatus
      • getCapabilities
      • grantPermissions
    • Other signers (Auth Providers)
      • EOA wallets (Metamask, Phantom...)
      • Magic signer
      • Web3Auth signer
      • Turnkey signer
      • Privy signer
  • 🔌Integrations
    • React hooks
      • ConnectProvider
      • useAccount
      • useConnect
      • useDisconnect
      • useGetGasPrice
      • useSendTransaction
      • useSignMessage
      • useVerifyMessage
      • useWriteContract
      • Handle owners
        • useRemoveOwner
        • useValidateAddDevice
        • useCreateNewSigner
        • useAddOwner
        • useGetOwners/EnrichedOwners
      • Session Keys
        • useGrantPermission
        • useSendPermission
        • useSessionKeyClient
        • useSessionKeySigner
      • Recovery
        • useIsRecoveryActive
        • useSetUpRecovery
        • useGetRecoveryRequest
        • useCancelRecoveryRequest
    • Mobile SDKs
      • IOS
      • Android
      • React Native
    • Wagmi
  • SDK Core
    • Signers (Auth Providers)
      • EOA wallets (Metamask, Phantom...)
      • Magic signer
      • Web3Auth signer
      • Turnkey signer
      • Privy signer
    • Handle owners
    • Capabilities
      • sendCalls
      • getCallsStatus
      • getCapabilities
  • SDK Session Keys
    • Setup Smart Account Client
    • Manage session keys
    • Policies
      • Sudo policy
      • Action policy
  • 📦Bundler
    • Bundler API
      • eth_sendUserOperation
      • eth_estimateUserOperationGas
      • eth_getUserOperationByHash
      • eth_getUserOperationReceipt
      • eth_supportedEntryPoints
  • 💳Paymaster
    • Paymaster API
  • 📖RESOURCES
    • Migrate from the connect legacy SDK
    • Connect Legacy SDKs (Unity, JS)
    • FAQ
Powered by GitBook
On this page
  • Description
  • Returns
  • Example
  1. Integrations
  2. React hooks

useDisconnect

Description

This hook provides functionality for disconnecting from a smart account. It handles the disconnection process and manages related states, such as whether the process is pending or if an error occurred. The hook can execute both synchronously and asynchronously.

Returns

The useDisconnect hook returns an object containing the following properties and functions:

  • disconnect (() => void): A synchronous function to disconnect from the smart account. It manages internal states such as pending and error states.

  • disconnectAsync (() => Promise<void>): An asynchronous function to disconnect from the smart account, returning a promise. This function allows the use of async/await syntax for handling the disconnection process.

  • isPending (boolean): A boolean indicating whether the disconnection process is currently pending.

  • error (Error | null): An error object if an error occurred during the disconnection process, otherwise null.

Example

import React from 'react';
import { useDisconnect } from "@cometh/connect-react-hooks";

const DisconnectButton = () => {
  const { disconnect, isPending, error } = useDisconnect();

  return (
    <div>
      <button onClick={disconnect} disabled={isPending}>
        {isPending ? 'Disconnecting...' : 'Disconnect'}
      </button>
      {error && <p style={{ color: 'red' }}>Error: {error.message}</p>}
    </div>
  );
};

export default DisconnectButton;
PrevioususeConnectNextuseGetGasPrice

Last updated 9 months ago

🔌