Skip to main content

useRemoveChainByGenesisHash

Hook to remove a chain by a genesis hash.

Usage

import { useChains, useRemoveChainByGenesisHash } from '@kibisis/katavault-react';

function Chains() {
const chains = useChains();
const removeChainByGenesisHash = useRemoveChainByGenesisHash();
const handleOnRemoveChainClick = useCallback((genesisHash: string) => () => {
removeChainByGenesisHash(genesisHash, {
onError: (error) => {
console.error(error);
},
onSuccess: () => {
console.log(`removed chain ${genesisHash}`);
},
});
}, [removeAccount]);

return (
<div>
{chains.map(({ displayName, genesisHash, genesisID }) => (
<div>
<p>Name: {displayName}</p>
<p>ID: {genesisID}</p>
<button onClick={handleOnRemoveChainClick(genesisHash)}>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 chain removal was successful.

See also