Skip to content

disconnect

Usage

connect() must be called and WalletConnect session must be initiated before account information will be returned.

import { disconnect, useAccount } from '@puzzlehq/sdk';
import { useState } from 'react';
export const ConnectPage = () => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | undefined>();
const { account } = useAccount();
const onClick = async () => {
setLoading(true);
setError(undefined);
try {
await disconnect()
} catch (e) {
setError((e as Error).message);
} finally {
setLoading(false);
}
}
return (
<div>
<button
onClick={ onClick }
disabled={ loading }
>
disconnect from puzzle
</button>
{ account && <p>you are connected to puzzle</p> }
{ !account && <p>you are not connected to puzzle</p> }
{ error && <p>error connecting: {error}</p> }
</div>
)
}