useAccountSubnames
A React hook for fetching subnames owned by a connected account.
Usage
import { useAccountSubnames } from '@justaname.id/react'
function AccountSubnamesComponent() {
const {
accountSubnames,
isAccountSubnamesPending,
isAccountSubnamesFetching,
isAccountSubnamesLoading,
refetchAccountSubnames
} = useAccountSubnames()
if (isAccountSubnamesLoading) return <div>Loading subnames...</div>
return (
<div>
<h3>Your Subnames</h3>
{accountSubnames?.map((record, index) => (
<div key={index}>
<strong>{record.ens}</strong>
<p>{record.sanitizedRecords?.description}</p>
<p>Claimed: {record.isClaimed ? 'Yes' : 'No'}</p>
</div>
))}
<button onClick={refetchAccountSubnames}>Refresh</button>
</div>
)
}
Returns
UseAccountSubnamesResult
- An object containing:
accountSubnames
: Array ofRecords
objects containing subname data withsanitizedRecords
propertyisAccountSubnamesPending
: Boolean indicating if the data is being fetchedisAccountSubnamesFetching
: Boolean indicating if the data is being fetchedisAccountSubnamesLoading
: Boolean indicating if the data is loadingrefetchAccountSubnames
: Function to manually refetch the data
Parameters
params?:
UseConnectedWalletSubnamesOptions
- Optional parameters for the hook
Defined in
packages/@justaname.id/react/src/lib/hooks/account/useAccountSubnames.ts:27
Last updated
Was this helpful?