Skip to main content

useRemoveAccount

Hook to remove an account.

Usage

import { useAccounts, useRemoveAccount } from '@kibisis/katavault-react';

function Accounts() {
const accounts = useAccounts();
const removeAccount = useRemoveAccount();
const handleOnRemoveAccountClick = useCallback((address: string) => () => {
removeAccount(address, {
onError: (error) => {
console.error(error);
},
onSuccess: () => {
console.log(`removed account ${address}`);
},
});
}, [removeAccount]);

return (
<div>
{accounts.map(({ address, name }) => (
<div>
<p>Address: {address}</p>
<p>Name: {name ?? '-'}</p>
<button onClick={handleOnRemoveAccountClick(address)}>Remove</button>
</div>
))}
</div>
);
}

Returns

(params: string, options?: { onError, onSuccess }) => void

The function can be called with callbacks that are invoked on error/success.

onError

(error: BaseError, params: string) => void | Promimse<void>

This will be invoked if there was an error.

onSuccess

(result: undefined, params: string) => void | Promimse<void>

This will be invoked if the account removal was successful.

See also