Skip to main content

Function: useUserEndorsement()

useUserEndorsement(eprintUri, userDid, options): UseQueryResult<null | EndorsementView, Error>

Defined in: web/lib/hooks/use-endorsement.ts:292

Checks if a user has endorsed an eprint.

Parameters​

eprintUri​

string

AT-URI of the eprint

userDid​

string

DID of the user to check

options​

UseEndorsementsOptions = {}

Hook options

Returns​

UseQueryResult<null | EndorsementView, Error>

Query result with user's endorsement or null

Remarks​

Returns the user's endorsement if it exists, or null if not. Useful for showing/hiding the endorsement form and displaying user's existing endorsement.

Example​

const { data: userEndorsement, isLoading } = useUserEndorsement(
eprintUri,
currentUser.did
);

if (userEndorsement) {
return <YourEndorsement endorsement={userEndorsement} />;
}

return <EndorsementForm eprintUri={eprintUri} />;