UNPKG

@lens-protocol/react

Version:

Interacting with the Lens Protocol API using React.

54 lines (53 loc) 1.9 kB
import { AnyPublication, PublicationRequest, 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 { PublicationRequest }; /** * {@link usePublication} hook arguments */ export type UsePublicationArgs = OneOf<PublicationRequest>; /** * {@link usePublication} hook arguments with Suspense support * * @experimental This API can change without notice */ export type UseSuspensePublicationArgs = SuspenseEnabled<UsePublicationArgs>; export type UsePublicationResult = ReadResult<AnyPublication, NotFoundError | UnspecifiedError> | SuspenseResultWithError<AnyPublication, NotFoundError>; /** * Fetch a publication by either its publication id or transaction hash. * * ```ts * const { data, error, loading } = usePublication({ * forId: '0x04-0x0b', * // OR * forTxHash: '0xcd0655e8d1d131ebfc72fa5ebff6ed0430e6e39e729af1a81da3b6f33822a6ff', * }); * ``` * * @category Publications * @group Hooks * * @param args - {@link UsePublicationArgs} */ export declare function usePublication({ forId, forTxHash, }: UsePublicationArgs): ReadResult<AnyPublication, NotFoundError | UnspecifiedError>; /** * Fetch a publication by either its publication id or transaction hash. * * This signature supports [React Suspense](https://react.dev/reference/react/Suspense). * * ```ts * const { data } = usePublication({ * forId: '0x04-0x0b', * suspense: true, * }); * * console.log(data.id); * ``` * * @experimental This API can change without notice * @category Publications * @group Hooks */ export declare function usePublication(args: UseSuspensePublicationArgs): SuspenseResultWithError<AnyPublication, NotFoundError>;