reference
useYagna
useYagna
is a hook that provides information about the Yagna connection status. If the connection cannot be established, the hook will retry using an exponential backoff algorithm. It returns an object with the following properties:
Name | Description |
---|---|
isConnected | Boolean indicating whether the connection to Yagna is established. |
isLoading | Boolean indicating whether the connection to Yagna is being established. |
error | Error object containing information about the error that occurred while connecting to Yagna. |
reconnect | A function that can be used to reconnect to Yagna. |
Parameters
This hook doesn't accept any parameters.
Example
function MyComponent() {
const { isConnected, reconnect, isLoading, error } = useYagna()
if (isLoading) {
return <div>Loading...</div>
}
return (
<div>
<div>Yagna is {isConnected ? 'connected' : 'disconnected'}</div>
<button onClick={reconnect} disabled={isConnected}>
Reconnect
</button>
{error && <div>Error: {error.toString()}</div>}
</div>
)
}
Was this helpful?