@lens-protocol/react
Version:
Interacting with the Lens Protocol API using React.
63 lines (62 loc) • 1.86 kB
TypeScript
import { Profile, ProfileRequest, UnspecifiedError } from '@lens-protocol/api-bindings';
import { OneOf } from '@lens-protocol/shared-kernel';
import { NotFoundError } from "../NotFoundError.js";
import { ReadResult } from "../helpers/reads.js";
import { SuspenseEnabled, SuspenseResultWithError } from "../helpers/suspense.js";
export type { ProfileRequest };
/**
* {@link useProfile} hook arguments
*/
export type UseProfileArgs = OneOf<ProfileRequest>;
/**
* {@link useProfile} hook arguments with Suspense support
*
* @experimental This API can change without notice
*/
export type UseSuspenseProfileArgs = SuspenseEnabled<UseProfileArgs>;
export type UseProfileResult = ReadResult<Profile, NotFoundError | UnspecifiedError> | SuspenseResultWithError<Profile, NotFoundError>;
/**
* Fetches a Profile by either its full handle or id.
*
* ```ts
* const { data, error, loading } = useProfile({
* forHandle: 'lens/stani',
* // OR
* forProfileId: '0x04',
* });
*
* if (loading) {
* return <Loading />;
* }
*
* if (error) {
* return <Error error={error} />;
* }
*
* return <Profile profile={data} />;
* ```
*
* @category Profiles
* @group Hooks
* @param args - {@link UseProfileArgs}
*/
export declare function useProfile({ forHandle, forProfileId, }: UseProfileArgs): ReadResult<Profile, NotFoundError | UnspecifiedError>;
/**
* Fetches a Profile by either its full handle or id.
*
* This signature supports [React Suspense](https://react.dev/reference/react/Suspense).
*
* ```ts
* const { data } = useProfile({
* forHandle: 'lens/stani',
* suspense: true,
* });
*
* console.log(data.id);
* ```
*
* @experimental This API can change without notice
* @category Profiles
* @group Hooks
*/
export declare function useProfile(args: UseSuspenseProfileArgs): SuspenseResultWithError<Profile, NotFoundError>;