Skip to main content

useDisconnect

Mutation hook to execute wallet disconnection with optional arguments to invoke given functions on error, loading, or success event.

Usage

import { useAccount, useDisconnect } from "graz";

function App() {
const { disconnect } = useDisconnect();

return (
<div>
<button onClick={() => disconnect()}>Disconnect</button>}
</div>
);
}
Disconnect a specific chain
import { useAccount, useDisconnect } from "graz";

function App() {
const { disconnect } = useDisconnect();

return (
<div>
<button onClick={() => disconnect({chainId?: ["cosmoshub-4"] })}>Disconnect</button>
</div>
);
}

Hook Params

{
onError?: (error: unknown, data: boolean) => void
onMutate?: (data: boolean) => void
onSuccess?: (data: boolean) => void
}

Return Value

{
disconnect: (forget?: boolean) => void;
disconnectAsync: (forget?: boolean) => Promise<void>;
error: unknown;
isLoading: boolean;
isSuccess: boolean;
status: "error" | "idle" | "loading" | "success";
}